<html>
<head>
<title>traffic-Simulation-demo211</title>
<style type="text/css">
<!--
/*
    This style sheet is borrowed from the NetLogo User Manual.  However, some of the units were
    changed from em to px because Java's StyleSheet support is limited for relative units such as
    em and % (this will supposively improve with newer versions of the VM) - jrn 7/21/05
    BE VERY VERY CAREFUL when you alter this style sheet -- it's possible to put in
    innocent-looking things that work on some VM's but cause Java exceptions on other for example
    we were using "font-size: 125%" but it caused Java exceptions on Java 1.5 on Windows - ST
    8/25/05
*/
:link { color: rgb(110,0,110); }
:visited { color: rgb(110,0,110); }
body {
    margin-left: 5px;
    font-family: arial, sans-serif;
    background: white;
    font-size: 12pt
}
h1 {
    color: white;
    background: rgb(45,0,45);
    font-size: 18pt;
    margin-bottom: 4px;
    padding-left: 6px;
    padding-right: 6px;
    padding-top: 6px;
    padding-bottom: 6px;
}
h2 {
    margin-top: 15px;
    margin-left: 6px;
    margin-bottom: 4px;
    background: rgb(166,172,255);
    font-size: 15pt;
    padding-left: 6px;
    padding-right: 6px;
    padding-top: 6px;
    padding-bottom: 6px;
}
h3 {
    margin-top: 15px;
    margin-left: 13px;
    margin-bottom: 4px;
    background: rgb(175,175,175);
    font-size: 12pt;
    padding: 0.2em;
    padding-left: 6px;
    padding-right: 6px;
    padding-top: 6px;
    padding-bottom: 6px;
}
h4 {
    margin-top: 15px;
    margin-bottom: 5px;
    margin-left: 15px;
    font-size: 12pt;
}
h5 {
    margin-top: 15px;
    margin-left: 15px;
    font-size: 12pt;
}
h6 {
    margin-top: 15px;
    margin-left: 15px;
    font-size: 12pt;
}
p {
    margin-left: 15px;
    margin-bottom: 3px;
}
pre {
    margin-left: 13px;
    background: rgb(225,225,225);
    font-family: monospace;
    font-size: 12pt;
    padding-left: 10px;
    padding-right: 3px;
    padding-top: 7px;
    padding-bottom: 7px;
    margin-top:9px;
    margin-bottom:0px;
}
code {
    font-family: monospace;
    font-size: 12pt;
}
blockquote {
    border: solid;
    border-style: solid;
    border-width: thin;
    border-color: black;
    background: rgb(250,250,220);
    padding-top: 0px;
    padding-bottom: 7px;
    margin-top: 7px;
    margin-bottom:1px;
}
ol {
   margin-bottom:1px;
}
ul {
   margin-bottom:1px;
}

-->
</style>
</head>
<body>

<p>This page was automatically generated by NetLogo 5.0.3.</p>

<p>The applet requires Java 5 or higher.
Java must be enabled in your browser settings.
Mac users must have Mac OS X 10.4 or higher.
Windows and Linux users may obtain the latest Java from
<a href="http://www.java.com/">Oracle's Java site</a>.</p>

<p><hr>

<p><font size="-1">In order for this to work, this file, your model file
(traffic-Simulation-demo211.nlogo), and the files NetLogoLite.jar and NetLogoLite.jar.pack.gz
must all be in the same directory.  (You can copy NetLogoLite.jar and NetLogoLite.jar.pack.gz
from the directory where you installed NetLogo.)</font></p>

<p><font size="-1">The applet will also need access to the 
gis extension.
Copy the entire directory for each required extension into the same
directory as the applet.</font></p>

<p><font size="-1">On some systems, you can test the applet locally on your computer
before uploading it to a web server.  It doesn't work on all systems,
though, so if it doesn't work from your hard drive, please try
uploading it to a web server.</font></p>

<p><font size="-1">You don't need to include everything in this file in your page.
If you want, you can just take the HTML code beginning with
&lt;applet&gt; and ending with &lt;/applet&gt;, and paste it into any HTML
file you want.  It's even OK to put multiple &lt;applet&gt; tags
on a single page.</font></p>

<p><font size="-1">If the NetLogoLite files and your model are in different
directories, you must modify the archive= and value= lines
in the HTML code to point to their actual locations.
(For example, if you have multiple applets in different
directories on the same web server, you may want to put
a single copy of the NetLogoLite files in one central place and
change the archive= lines of all the HTML files to point
to that one central copy.  This will save disk space for
you and download time for your users.)</font></p>

<p>
<applet code="org.nlogo.lite.Applet"
        archive="NetLogoLite.jar,gis/gis.jar,gis/jai_codec-1.1.3.jar,gis/jai_core-1.1.3.jar,gis/ngunits-1.0.jar,gis/jts-1.9.jar,gis/commons-codec-1.3.jar,gis/commons-logging-1.1.jar,gis/commons-httpclient-3.0.1.jar"
        width="983" height="446">
  <param name="DefaultModel"
         value="traffic-Simulation-demo211.nlogo">
  <param name="java_arguments"
         value="-Djnlp.packEnabled=true">
</applet>
</p>

<p>powered by
<a target="_blank" href="http://ccl.northwestern.edu/netlogo/">NetLogo</a></p>

<p>view/download model file:
<a href="traffic-Simulation-demo211.nlogo">traffic-Simulation-demo211.nlogo</a></p>
<h2>WHAT IS IT?</h2><p>This section could give a general understanding of what the model is trying to show or explain.</p><h2>HOW IT WORKS</h2><p>This section could explain what rules the agents use to create the overall behavior of the model.</p><h2>HOW TO USE IT</h2><p>This section could explain how to use the model, including a description of each of the items in the interface tab.</p><h2>THINGS TO NOTICE</h2><p>This section could give some ideas of things for the user to notice while running the model.</p><h2>THINGS TO TRY</h2><p>This section could give some ideas of things for the user to try to do (move sliders, switches, etc.) with the model.</p><h2>EXTENDING THE MODEL</h2><p>This section could give some ideas of things to add or change in the procedures tab to make the model more complicated, detailed, accurate, etc.</p><h2>NETLOGO FEATURES</h2><p>This section could point out any especially interesting or unusual features of NetLogo that the model makes use of, particularly in the Procedures tab. It might also point out places where workarounds were needed because of missing features.</p><h2>RELATED MODELS</h2><p>This section could give the names of models in the NetLogo Models Library or elsewhere which are of related interest.</p><h2>CREDITS AND REFERENCES</h2><p>This section could contain a reference to the model&rsquo;s URL on the web if it has one, as well as any other necessary credits or references.</p>

<h1>CODE</h1>
<pre><font color="#007f69">extensions</font><font color="#000000"> [gis]
</font><font color="#007f69">globals</font><font color="#000000"> [f g wlist blist line-feature R-square time-series printTime agentVision numOfAgents agentSize roadTotalLength acceleration street-list streetFeatures streetdata last-node visited-list tracked-list visited-goal-list tracked-goal-list connect-list connect-rs-list ltg-list wpr-list wpr-rs-list betweeness-list betweeness-rs-list countAbnormal countAbnormal1 maxBound currLineDepth currLevel pathList degree currPath currDegree pathIDsList street_shp mylist a b c d]
</font><font color="#660096">breed</font><font color="#000000"> [nodes node]
</font><font color="#660096">breed</font><font color="#000000"> [destinations destination]
</font><font color="#660096">breed</font><font color="#000000"> [people person]
</font><font color="#660096">breed</font><font color="#000000"> [goalmen goalman]
</font><font color="#007f69">people-own</font><font color="#000000"> [cur-street last-street next-street cur-length junc-length junc-point last-location cur-travelTime travelTime direction speed]
</font><font color="#007f69">goalmen-own</font><font color="#000000"> [cur-street last-street next-street cur-length junc-length junc-point last-location cur-travelTime travelTime direction path-goal dest-street dest-x dest-y speed]

</font><font color="#5a5a5a">;Load a shapefile polyline data as the streetNetwork</font><font color="#000000">
</font><font color="#007f69">to</font><font color="#000000"> Setup
  </font><font color="#5a5a5a">;; (for this model to work with NetLogo's new plotting features,</font><font color="#000000">
  </font><font color="#5a5a5a">;; __clear-all-and-reset-ticks should be replaced with clear-all at</font><font color="#000000">
  </font><font color="#5a5a5a">;; the beginning of your setup procedure and reset-ticks at the end</font><font color="#000000">
  </font><font color="#5a5a5a">;; of the procedure.)</font><font color="#000000">
  </font><font color="#0000aa">__clear-all-and-reset-ticks</font><font color="#000000">
  </font><font color="#0000aa">ask</font><font color="#000000"> </font><font color="#660096">patches</font><font color="#000000"> [</font><font color="#0000aa">set</font><font color="#000000"> </font><font color="#660096">pcolor</font><font color="#000000"> </font><font color="#963700">white</font><font color="#000000">]
 </font><font color="#5a5a5a">; gis:load-coordinate-system &quot;data1/avignon_NaturalRoadsAxialNew.prj&quot;</font><font color="#000000">
  </font><font color="#0000aa">set</font><font color="#000000"> street_shp </font><font color="#660096">gis:load-dataset</font><font color="#000000"> </font><font color="#963700">&quot;data1/avignon_NaturalRoadsAxialNew.shp&quot;</font><font color="#000000">
  </font><font color="#0000aa">gis:set-world-envelope</font><font color="#000000"> (</font><font color="#660096">gis:envelope-union-of</font><font color="#000000"> (</font><font color="#660096">gis:envelope-of</font><font color="#000000"> street_shp))
  
  </font><font color="#0000aa">set</font><font color="#000000"> mylist []
  </font><font color="#0000aa">set</font><font color="#000000"> line-feature(</font><font color="#660096">gis:feature-list-of</font><font color="#000000"> street_shp)
  </font><font color="#5a5a5a">;add endpoints of line features into an empty list, for a line list the format list(x1,y1,x2,y2)</font><font color="#000000">
  </font><font color="#0000aa">foreach</font><font color="#000000"> line-feature </font><font color="#5a5a5a">; replace the shp with the list </font><font color="#000000">
  [
    </font><font color="#0000aa">let</font><font color="#000000"> p1 </font><font color="#660096">gis:location-of</font><font color="#000000">(</font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">0</font><font color="#000000">(</font><font color="#660096">first</font><font color="#000000"> (</font><font color="#660096">gis:vertex-lists-of</font><font color="#000000"> ?))) </font><font color="#5a5a5a">;item 0 obtain the first element of a list (the first vertex of a line). item 1 the second </font><font color="#000000">
    </font><font color="#0000aa">let</font><font color="#000000"> p2 </font><font color="#660096">gis:location-of</font><font color="#000000">(</font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000">(</font><font color="#660096">first</font><font color="#000000"> (</font><font color="#660096">gis:vertex-lists-of</font><font color="#000000"> ?)))
    </font><font color="#0000aa">ifelse</font><font color="#000000"> (</font><font color="#660096">length</font><font color="#000000"> p1 </font><font color="#660096">!=</font><font color="#000000"> </font><font color="#963700">0</font><font color="#000000"> ) </font><font color="#660096">and</font><font color="#000000"> (</font><font color="#660096">length</font><font color="#000000"> p2 </font><font color="#660096">!=</font><font color="#000000"> </font><font color="#963700">0</font><font color="#000000">) 
    [
      </font><font color="#0000aa">let</font><font color="#000000"> line (</font><font color="#660096">list</font><font color="#000000">(</font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">0</font><font color="#000000"> p1)(</font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000"> p1)(</font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">0</font><font color="#000000"> p2)(</font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000"> p2)) </font><font color="#5a5a5a">; p1--&gt;(x1,y1) item 0 p1--&gt;x1.... </font><font color="#000000">
      </font><font color="#0000aa">set</font><font color="#000000"> mylist </font><font color="#660096">lput</font><font color="#000000"> line mylist </font><font color="#5a5a5a">;lput--&gt; append every line to mylist</font><font color="#000000">
      ]
    []
    ]
  </font><font color="#0000aa">set</font><font color="#000000"> streetFeatures(mylist)
 </font><font color="#5a5a5a">;set streetFeatures gis:load-dataset &quot;barnsbury.shp&quot;</font><font color="#000000">
 </font><font color="#5a5a5a">;let myEnvelope gis:envelope-of streetFeatures</font><font color="#000000">
 </font><font color="#5a5a5a">;set myEnvelope (list ((item 0 myEnvelope)- 1)((item 1 myEnvelope)+ 1)((item 2 myEnvelope)- 1)((item 3 myEnvelope)+ 1)) </font><font color="#000000">
 </font><font color="#5a5a5a">;gis:set-world-envelope myEnvelope</font><font color="#000000">
 </font><font color="#5a5a5a">; set streetFeatures (list (list -19.847113930873192 16.392979979993694 -15.147226751807644 -19.507363050458817) (list -20.30011510475903 14.41109984424316 -11.693092800928143 19.110987023308713) (list -19.2808624635159 5.2944512197907105 -8.012458263105724 6.823330181655407) (list -17.015856594086717 -10.334089279270636 20.016989371080385 2.576444176475694) (list -15.54360277895775 -19.224237316780172 20.30011510475903 2.972820203625801) (list -13.731598083414406 19.507363050458817 19.73386363740174 8.748585170670209) (list -5.067950632847789 17.582108061444018 -8.975085757613126 5.804077540412275) (list -8.918460610877396 7.616082235955621 -5.124575779583518 -6.823330181655407) (list -2.9161950568900687 9.711212665177612 4.1619482850761225 -8.352209143520103) (list 18.374860115744234 10.220838985799178 19.167612170044446 -0.19818801357505164) (list 5.5209518067336285 14.014723817093058 8.465459436991564 2.6330693232114224) (list -7.955833116369996 10.787090453156473 -1.8969424156469368 9.088336051084589) (list -0.19818801357505164 0.9343149211395372 19.280862463515902 5.7474523936765465))</font><font color="#000000">
  </font><font color="#5a5a5a">;set streetFeatures (list)</font><font color="#000000">
  </font><font color="#5a5a5a">;ReadData</font><font color="#000000">
  </font><font color="#0000aa">set</font><font color="#000000"> streetdata (</font><font color="#660096">list</font><font color="#000000">)
  </font><font color="#0000aa">set</font><font color="#000000"> street-list (</font><font color="#660096">list</font><font color="#000000">)
  </font><font color="#0000aa">set</font><font color="#000000"> wlist (</font><font color="#660096">list</font><font color="#000000">)
  </font><font color="#0000aa">set</font><font color="#000000"> blist (</font><font color="#660096">list</font><font color="#000000">) 
  </font><font color="#0000aa">set</font><font color="#000000"> countAbnormal (</font><font color="#660096">list</font><font color="#000000">)
  </font><font color="#0000aa">set</font><font color="#000000"> countAbnormal1 </font><font color="#963700">0</font><font color="#000000">
  </font><font color="#0000aa">set</font><font color="#000000"> acceleration </font><font color="#963700">0.1</font><font color="#000000">
  </font><font color="#0000aa">set</font><font color="#000000"> agentSize </font><font color="#963700">0.5</font><font color="#000000">
  </font><font color="#0000aa">set</font><font color="#000000"> agentVision </font><font color="#963700">2</font><font color="#000000">
  </font><font color="#0000aa">set</font><font color="#000000"> roadTotalLength </font><font color="#963700">0</font><font color="#000000">
  </font><font color="#0000aa">set</font><font color="#000000"> printTime </font><font color="#963700">1</font><font color="#000000">
  ConvertToLinks
  </font><font color="#0000aa">set</font><font color="#000000"> time-series </font><font color="#660096">n-values</font><font color="#000000"> </font><font color="#963700">10</font><font color="#000000"> [</font><font color="#963700">0</font><font color="#000000">]
  </font><font color="#0000aa">set</font><font color="#000000"> wpr-rs-list (</font><font color="#660096">list</font><font color="#000000">)
  </font><font color="#0000aa">set</font><font color="#000000"> wpr-list (</font><font color="#660096">list</font><font color="#000000">)
  </font><font color="#0000aa">set</font><font color="#000000"> connect-list (</font><font color="#660096">list</font><font color="#000000">)
  </font><font color="#0000aa">set</font><font color="#000000"> ltg-list (</font><font color="#660096">list</font><font color="#000000">)
  </font><font color="#0000aa">set</font><font color="#000000"> betweeness-list (</font><font color="#660096">list</font><font color="#000000">)
  </font><font color="#0000aa">set</font><font color="#000000"> betweeness-rs-list (</font><font color="#660096">list</font><font color="#000000">)
  </font><font color="#5a5a5a">; set visited-list n-values (length streetdata) [0]</font><font color="#000000">
  </font><font color="#0000aa">set</font><font color="#000000"> visited-list </font><font color="#660096">n-values</font><font color="#000000"> </font><font color="#963700">425</font><font color="#000000"> [</font><font color="#963700">0</font><font color="#000000">]
  </font><font color="#5a5a5a">;set tracked-list n-values (length streetdata) [0]</font><font color="#000000">
  </font><font color="#0000aa">set</font><font color="#000000"> tracked-list </font><font color="#660096">n-values</font><font color="#000000"> </font><font color="#963700">425</font><font color="#000000"> [</font><font color="#963700">0</font><font color="#000000">]
  </font><font color="#0000aa">set</font><font color="#000000"> visited-goal-list </font><font color="#660096">n-values</font><font color="#000000"> (</font><font color="#660096">length</font><font color="#000000"> streetdata) [</font><font color="#963700">0</font><font color="#000000">]
  </font><font color="#0000aa">set</font><font color="#000000"> tracked-goal-list </font><font color="#660096">n-values</font><font color="#000000"> (</font><font color="#660096">length</font><font color="#000000"> streetdata) [</font><font color="#963700">0</font><font color="#000000">]
  </font><font color="#0000aa">set</font><font color="#000000"> numOfAgents car-number
  </font><font color="#0000aa">set</font><font color="#000000"> maxBound </font><font color="#660096">length</font><font color="#000000"> streetdata
  SetMeasureList
  ConstructConnectivityGraph
  InitialSimu
</font><font color="#007f69">end</font><font color="#000000">
</font><font color="#5a5a5a">;Read the wpr value from the netlogo file</font><font color="#000000">
</font><font color="#007f69">to</font><font color="#000000"> SetMeasureList
  </font><font color="#0000aa">file-open</font><font color="#000000"> </font><font color="#963700">&quot;connect.txt&quot;</font><font color="#000000">
  </font><font color="#0000aa">set</font><font color="#000000"> connect-list </font><font color="#660096">file-read</font><font color="#000000">
  </font><font color="#0000aa">file-close</font><font color="#000000">
  </font><font color="#0000aa">file-open</font><font color="#000000"> </font><font color="#963700">&quot;ltg.txt&quot;</font><font color="#000000">
  </font><font color="#0000aa">set</font><font color="#000000"> ltg-list </font><font color="#660096">file-read</font><font color="#000000">
  </font><font color="#0000aa">file-close</font><font color="#000000">
  </font><font color="#0000aa">file-open</font><font color="#000000"> </font><font color="#963700">&quot;wpr.txt&quot;</font><font color="#000000">
  </font><font color="#0000aa">set</font><font color="#000000"> wpr-list </font><font color="#660096">file-read</font><font color="#000000">
  </font><font color="#0000aa">file-close</font><font color="#000000">
  </font><font color="#0000aa">file-open</font><font color="#000000"> </font><font color="#963700">&quot;betweeness.txt&quot;</font><font color="#000000">
  </font><font color="#0000aa">set</font><font color="#000000"> betweeness-list </font><font color="#660096">file-read</font><font color="#000000">
  </font><font color="#0000aa">file-close</font><font color="#000000">
   (</font><font color="#0000aa">foreach</font><font color="#000000"> wpr-list betweeness-list
  [
    
      </font><font color="#5a5a5a">;let list1 (list ?)</font><font color="#000000">
      </font><font color="#0000aa">set</font><font color="#000000"> wlist </font><font color="#660096">lput</font><font color="#000000"> ?1 wlist
      </font><font color="#0000aa">set</font><font color="#000000"> blist </font><font color="#660096">lput</font><font color="#000000"> ?2 blist
      </font><font color="#0000aa">ifelse</font><font color="#000000"> </font><font color="#660096">length</font><font color="#000000">(blist) </font><font color="#660096">&gt;</font><font color="#000000"> </font><font color="#963700">424</font><font color="#000000"> </font><font color="#660096">and</font><font color="#000000"> </font><font color="#660096">length</font><font color="#000000">(wlist) </font><font color="#660096">&gt;</font><font color="#000000"> </font><font color="#963700">424</font><font color="#000000">
      [</font><font color="#0000aa">stop</font><font color="#000000">]
      []
     ])
  
  
 
</font><font color="#007f69">end</font><font color="#000000">
</font><font color="#5a5a5a">;Read the netlogo street network file</font><font color="#000000">
</font><font color="#5a5a5a">;to ReadData</font><font color="#000000">
 </font><font color="#5a5a5a">;file-open &quot;barnsbury.txt&quot;</font><font color="#000000">
  </font><font color="#5a5a5a">;while [not file-at-end?]</font><font color="#000000">
  </font><font color="#5a5a5a">;[</font><font color="#000000">
   </font><font color="#5a5a5a">; let streetEle file-read</font><font color="#000000">
    </font><font color="#5a5a5a">;let axialline (list (item 2 streetEle) (item 3 streetEle) (item 4 streetEle) (item 5 streetEle))</font><font color="#000000">
    </font><font color="#5a5a5a">;set streetFeatures lput axialline streetFeatures</font><font color="#000000">
  </font><font color="#5a5a5a">;]</font><font color="#000000">
  </font><font color="#5a5a5a">;file-close</font><font color="#000000">
</font><font color="#5a5a5a">;end </font><font color="#000000">
</font><font color="#5a5a5a">;Generate agents and locate them on the streets</font><font color="#000000">
</font><font color="#007f69">to</font><font color="#000000"> InitialSimu
  </font><font color="#0000aa">ifelse</font><font color="#000000"> MovingBehavior </font><font color="#660096">=</font><font color="#000000"> </font><font color="#963700">&quot;Random&quot;</font><font color="#000000">
  [
    GenerateRandomAgents 
  ]
  [
    GeneratePurposiveAgents
  ]
</font><font color="#007f69">end</font><font color="#000000">
</font><font color="#5a5a5a">;Convert shapefile data to link</font><font color="#000000">
</font><font color="#007f69">to</font><font color="#000000"> ConvertToLinks
  </font><font color="#0000aa">foreach</font><font color="#000000"> streetFeatures
  [
    </font><font color="#0000aa">let</font><font color="#000000"> street (</font><font color="#660096">list</font><font color="#000000">)
    create-nodes </font><font color="#963700">1</font><font color="#000000">
    [
      </font><font color="#0000aa">setxy</font><font color="#000000"> (</font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">0</font><font color="#000000"> ?)(</font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000"> ?)
      </font><font color="#0000aa">set</font><font color="#000000"> </font><font color="#660096">size</font><font color="#000000"> </font><font color="#963700">0.5</font><font color="#000000">
      </font><font color="#0000aa">set</font><font color="#000000"> </font><font color="#660096">shape</font><font color="#000000"> </font><font color="#963700">&quot;circle&quot;</font><font color="#000000">
      </font><font color="#0000aa">set</font><font color="#000000"> </font><font color="#660096">hidden?</font><font color="#000000"> </font><font color="#963700">true</font><font color="#000000">
      </font><font color="#0000aa">set</font><font color="#000000"> last-node </font><font color="#660096">self</font><font color="#000000">
    ]
    create-nodes </font><font color="#963700">1</font><font color="#000000">
    [    
      </font><font color="#0000aa">setxy</font><font color="#000000"> (</font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">2</font><font color="#000000"> ?)(</font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">3</font><font color="#000000"> ?)
      </font><font color="#0000aa">set</font><font color="#000000"> </font><font color="#660096">size</font><font color="#000000"> </font><font color="#963700">0.5</font><font color="#000000">
      </font><font color="#0000aa">set</font><font color="#000000"> </font><font color="#660096">shape</font><font color="#000000"> </font><font color="#963700">&quot;circle&quot;</font><font color="#000000">
      </font><font color="#0000aa">set</font><font color="#000000"> </font><font color="#660096">hidden?</font><font color="#000000"> </font><font color="#963700">true</font><font color="#000000">
      </font><font color="#0000aa">create-link-with</font><font color="#000000"> last-node
      [
        </font><font color="#0000aa">set</font><font color="#000000"> </font><font color="#660096">color</font><font color="#000000"> </font><font color="#963700">red</font><font color="#000000">
        </font><font color="#0000aa">set</font><font color="#000000"> </font><font color="#660096">thickness</font><font color="#000000"> </font><font color="#963700">0</font><font color="#000000">
        </font><font color="#0000aa">set</font><font color="#000000"> roadTotalLength roadTotalLength </font><font color="#660096">+</font><font color="#000000"> </font><font color="#660096">link-length</font><font color="#000000">
      ]
      </font><font color="#0000aa">set</font><font color="#000000"> street (</font><font color="#660096">list</font><font color="#000000"> [</font><font color="#660096">who</font><font color="#000000">] </font><font color="#660096">of</font><font color="#000000"> last-node </font><font color="#660096">who</font><font color="#000000"> [</font><font color="#660096">xcor</font><font color="#000000">] </font><font color="#660096">of</font><font color="#000000"> last-node [</font><font color="#660096">ycor</font><font color="#000000">] </font><font color="#660096">of</font><font color="#000000"> last-node </font><font color="#660096">xcor</font><font color="#000000"> </font><font color="#660096">ycor</font><font color="#000000">)
    ]
    </font><font color="#0000aa">set</font><font color="#000000"> streetdata </font><font color="#660096">lput</font><font color="#000000"> street streetdata    
  ]
</font><font color="#007f69">end</font><font color="#000000">
</font><font color="#5a5a5a">;Generate Purposive agents</font><font color="#000000">
</font><font color="#007f69">to</font><font color="#000000"> GeneratePurposiveAgents
  create-goalmen numOfAgents
  [
    </font><font color="#0000aa">let</font><font color="#000000"> streetId (</font><font color="#660096">random</font><font color="#000000"> </font><font color="#660096">length</font><font color="#000000"> streetdata)
    </font><font color="#0000aa">let</font><font color="#000000"> street (</font><font color="#660096">item</font><font color="#000000"> streetId streetdata)
    </font><font color="#0000aa">let</font><font color="#000000"> x1 </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">2</font><font color="#000000"> street
    </font><font color="#0000aa">let</font><font color="#000000"> y1 </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">3</font><font color="#000000"> street
    </font><font color="#0000aa">let</font><font color="#000000"> x2 </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">4</font><font color="#000000"> street
    </font><font color="#0000aa">let</font><font color="#000000"> y2 </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">5</font><font color="#000000"> street
    </font><font color="#0000aa">let</font><font color="#000000"> r1 </font><font color="#660096">random-float</font><font color="#000000"> </font><font color="#963700">1.0</font><font color="#000000">
    </font><font color="#0000aa">let</font><font color="#000000"> x (x1 </font><font color="#660096">+</font><font color="#000000"> (x2 </font><font color="#660096">-</font><font color="#000000"> x1)</font><font color="#660096">*</font><font color="#000000"> r1)
    </font><font color="#0000aa">let</font><font color="#000000"> y (y1 </font><font color="#660096">+</font><font color="#000000"> (y2 </font><font color="#660096">-</font><font color="#000000"> y1)</font><font color="#660096">*</font><font color="#000000"> r1)
    </font><font color="#0000aa">while</font><font color="#000000"> [</font><font color="#660096">any?</font><font color="#000000"> goalmen-on </font><font color="#660096">patch</font><font color="#000000"> x y]
    [
      </font><font color="#5a5a5a">; set streetId (random length streetdata)</font><font color="#000000">
      </font><font color="#0000aa">set</font><font color="#000000"> streetId </font><font color="#660096">random</font><font color="#000000"> </font><font color="#963700">425</font><font color="#000000">
      </font><font color="#0000aa">set</font><font color="#000000"> street </font><font color="#660096">item</font><font color="#000000"> streetId streetdata
      </font><font color="#0000aa">set</font><font color="#000000"> x1 </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">2</font><font color="#000000"> street
      </font><font color="#0000aa">set</font><font color="#000000"> y1 </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">3</font><font color="#000000"> street
      </font><font color="#0000aa">set</font><font color="#000000"> x2 </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">4</font><font color="#000000"> street
      </font><font color="#0000aa">set</font><font color="#000000"> y2 </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">5</font><font color="#000000"> street
      </font><font color="#0000aa">set</font><font color="#000000"> r1 </font><font color="#660096">random-float</font><font color="#000000"> </font><font color="#963700">1.0</font><font color="#000000">
      </font><font color="#0000aa">set</font><font color="#000000"> x (x1 </font><font color="#660096">+</font><font color="#000000"> (x2 </font><font color="#660096">-</font><font color="#000000"> x1)</font><font color="#660096">*</font><font color="#000000"> r1)
      </font><font color="#0000aa">set</font><font color="#000000"> y (y1 </font><font color="#660096">+</font><font color="#000000"> (y2 </font><font color="#660096">-</font><font color="#000000"> y1)</font><font color="#660096">*</font><font color="#000000"> r1)
    ]
    
    </font><font color="#0000aa">let</font><font color="#000000"> dStreetId Purposive_walker_behavior streetId
    </font><font color="#0000aa">let</font><font color="#000000"> dstreet </font><font color="#660096">item</font><font color="#000000"> dStreetId streetdata  </font><font color="#5a5a5a">;destination street</font><font color="#000000">
    </font><font color="#0000aa">let</font><font color="#000000"> x3 </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">2</font><font color="#000000"> dstreet
    </font><font color="#0000aa">let</font><font color="#000000"> y3 </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">3</font><font color="#000000"> dstreet
    </font><font color="#0000aa">let</font><font color="#000000"> x4 </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">4</font><font color="#000000"> dstreet
    </font><font color="#0000aa">let</font><font color="#000000"> y4 </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">5</font><font color="#000000"> dstreet
    </font><font color="#0000aa">let</font><font color="#000000"> r2 </font><font color="#660096">random-float</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000">
    </font><font color="#0000aa">let</font><font color="#000000"> x5 (x3 </font><font color="#660096">+</font><font color="#000000"> (x4 </font><font color="#660096">-</font><font color="#000000"> x3)</font><font color="#660096">*</font><font color="#000000"> r2)    </font><font color="#5a5a5a">;destination position x</font><font color="#000000">
    </font><font color="#0000aa">let</font><font color="#000000"> y5 (y3 </font><font color="#660096">+</font><font color="#000000"> (y4 </font><font color="#660096">-</font><font color="#000000"> y3)</font><font color="#660096">*</font><font color="#000000"> r2)    </font><font color="#5a5a5a">;destination position y</font><font color="#000000">
    
    </font><font color="#0000aa">setxy</font><font color="#000000"> x y
    </font><font color="#0000aa">set</font><font color="#000000"> </font><font color="#660096">size</font><font color="#000000"> agentSize
    </font><font color="#0000aa">set</font><font color="#000000"> </font><font color="#660096">color</font><font color="#000000"> </font><font color="#963700">green</font><font color="#000000">
    </font><font color="#0000aa">set</font><font color="#000000"> </font><font color="#660096">shape</font><font color="#000000"> </font><font color="#963700">&quot;car top&quot;</font><font color="#000000">
    </font><font color="#0000aa">set</font><font color="#000000"> speed simulation-speed
    
    </font><font color="#0000aa">set</font><font color="#000000"> cur-street streetId
    </font><font color="#0000aa">set</font><font color="#000000"> last-street </font><font color="#963700">-1</font><font color="#000000">
    </font><font color="#0000aa">set</font><font color="#000000"> next-street </font><font color="#963700">-1</font><font color="#000000">
    </font><font color="#0000aa">set</font><font color="#000000"> cur-length </font><font color="#660096">sqrt</font><font color="#000000">((</font><font color="#660096">xcor</font><font color="#000000"> </font><font color="#660096">-</font><font color="#000000"> x1)</font><font color="#660096">*</font><font color="#000000">(</font><font color="#660096">xcor</font><font color="#000000"> </font><font color="#660096">-</font><font color="#000000"> x1)</font><font color="#660096">+</font><font color="#000000">(</font><font color="#660096">ycor</font><font color="#000000"> </font><font color="#660096">-</font><font color="#000000"> y1)</font><font color="#660096">*</font><font color="#000000">(</font><font color="#660096">ycor</font><font color="#000000"> </font><font color="#660096">-</font><font color="#000000"> y1))
    </font><font color="#0000aa">set</font><font color="#000000"> junc-length </font><font color="#963700">-1</font><font color="#000000">
    </font><font color="#0000aa">set</font><font color="#000000"> junc-point (</font><font color="#660096">list</font><font color="#000000">)
    </font><font color="#0000aa">set</font><font color="#000000"> last-location (</font><font color="#660096">list</font><font color="#000000">)
    </font><font color="#0000aa">set</font><font color="#000000"> direction </font><font color="#963700">0</font><font color="#000000">
    </font><font color="#0000aa">set</font><font color="#000000"> dest-street dStreetId
    </font><font color="#0000aa">set</font><font color="#000000"> dest-x x5
    </font><font color="#0000aa">set</font><font color="#000000"> dest-y y5
    </font><font color="#5a5a5a">;calculate shortest path.</font><font color="#000000">
    </font><font color="#0000aa">set</font><font color="#000000"> path-goal GetPath </font><font color="#660096">xcor</font><font color="#000000"> </font><font color="#660096">ycor</font><font color="#000000"> cur-street x5 y5 dStreetId
    </font><font color="#5a5a5a">;Set the red color for the destination street</font><font color="#000000">
</font><font color="#5a5a5a">;    ask link (item 0 (item cur-street streetdata)) (item 1 (item cur-street streetdata)) </font><font color="#000000">
</font><font color="#5a5a5a">;    [</font><font color="#000000">
</font><font color="#5a5a5a">;      set color white</font><font color="#000000">
</font><font color="#5a5a5a">;    ] </font><font color="#000000">
</font><font color="#5a5a5a">;    ask destinations</font><font color="#000000">
</font><font color="#5a5a5a">;    [</font><font color="#000000">
</font><font color="#5a5a5a">;      die</font><font color="#000000">
</font><font color="#5a5a5a">;    ] </font><font color="#000000">
</font><font color="#5a5a5a">;    ask link (item 0 (item dest-street streetdata)) (item 1 (item dest-street streetdata)) </font><font color="#000000">
</font><font color="#5a5a5a">;    [</font><font color="#000000">
</font><font color="#5a5a5a">;      set color red</font><font color="#000000">
</font><font color="#5a5a5a">;    ]  </font><font color="#000000">
</font><font color="#5a5a5a">;    hatch-destinations 1</font><font color="#000000">
</font><font color="#5a5a5a">;    [</font><font color="#000000">
</font><font color="#5a5a5a">;      setxy x5 y5</font><font color="#000000">
</font><font color="#5a5a5a">;      set size 2.5</font><font color="#000000">
</font><font color="#5a5a5a">;      set shape &quot;flag&quot;</font><font color="#000000">
</font><font color="#5a5a5a">;      set color blue</font><font color="#000000">
</font><font color="#5a5a5a">;    ]   </font><font color="#000000">
    
    </font><font color="#0000aa">let</font><font color="#000000"> tracked </font><font color="#660096">item</font><font color="#000000"> streetId tracked-goal-list
    </font><font color="#0000aa">set</font><font color="#000000"> tracked tracked </font><font color="#660096">+</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000">
    </font><font color="#0000aa">set</font><font color="#000000"> tracked-goal-list </font><font color="#660096">replace-item</font><font color="#000000"> streetId tracked-goal-list tracked
    </font><font color="#0000aa">let</font><font color="#000000"> visited </font><font color="#660096">item</font><font color="#000000"> streetId visited-goal-list
    </font><font color="#0000aa">set</font><font color="#000000"> visited visited </font><font color="#660096">+</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000">
    </font><font color="#0000aa">set</font><font color="#000000"> visited-goal-list </font><font color="#660096">replace-item</font><font color="#000000"> streetId visited-goal-list visited      
  ]
</font><font color="#007f69">end</font><font color="#000000">
</font><font color="#5a5a5a">;Purposive agents behavior</font><font color="#000000">
</font><font color="#007f69">to-report</font><font color="#000000"> Purposive_walker_behavior [streetId]
  </font><font color="#0000aa">if</font><font color="#000000"> MovingBehavior </font><font color="#660096">=</font><font color="#000000"> </font><font color="#963700">&quot;Purposive I&quot;</font><font color="#000000">
  [
    </font><font color="#0000aa">let</font><font color="#000000"> nStreetId (</font><font color="#660096">random</font><font color="#000000"> </font><font color="#660096">length</font><font color="#000000"> streetdata)
    </font><font color="#0000aa">while</font><font color="#000000"> [nstreetId </font><font color="#660096">=</font><font color="#000000"> streetId]
    [
      </font><font color="#0000aa">set</font><font color="#000000"> nStreetId (</font><font color="#660096">random</font><font color="#000000"> </font><font color="#660096">length</font><font color="#000000"> streetdata)
    ]
    </font><font color="#0000aa">report</font><font color="#000000"> nStreetId
  ]
  </font><font color="#0000aa">if</font><font color="#000000"> MovingBehavior </font><font color="#660096">=</font><font color="#000000"> </font><font color="#963700">&quot;Purposive II&quot;</font><font color="#000000">
  [
    </font><font color="#0000aa">let</font><font color="#000000"> street-adjacent </font><font color="#660096">item</font><font color="#000000"> streetId street-list
    </font><font color="#0000aa">set</font><font color="#000000"> street-adjacent </font><font color="#660096">sublist</font><font color="#000000"> street-adjacent </font><font color="#963700">1</font><font color="#000000"> (</font><font color="#660096">length</font><font color="#000000"> street-adjacent)
    </font><font color="#0000aa">let</font><font color="#000000"> localStreets (</font><font color="#660096">list</font><font color="#000000">)
    </font><font color="#0000aa">let</font><font color="#000000"> tempStreets (</font><font color="#660096">list</font><font color="#000000">)
    </font><font color="#0000aa">let</font><font color="#000000"> globalStreets (</font><font color="#660096">list</font><font color="#000000">)
    </font><font color="#0000aa">foreach</font><font color="#000000"> street-adjacent
    [
      </font><font color="#0000aa">let</font><font color="#000000"> a-street-id </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">0</font><font color="#000000"> ?
      </font><font color="#0000aa">set</font><font color="#000000"> tempStreets </font><font color="#660096">lput</font><font color="#000000"> a-street-id tempStreets
      </font><font color="#0000aa">set</font><font color="#000000"> localStreets </font><font color="#660096">lput</font><font color="#000000"> a-street-id localStreets    
    ]  
    </font><font color="#0000aa">foreach</font><font color="#000000"> tempStreets
    [
      </font><font color="#0000aa">let</font><font color="#000000"> b-street-adjacent </font><font color="#660096">item</font><font color="#000000"> ? street-list
      </font><font color="#0000aa">set</font><font color="#000000"> b-street-adjacent </font><font color="#660096">sublist</font><font color="#000000"> b-street-adjacent </font><font color="#963700">1</font><font color="#000000"> (</font><font color="#660096">length</font><font color="#000000"> b-street-adjacent)
      </font><font color="#0000aa">foreach</font><font color="#000000"> b-street-adjacent
      [
        </font><font color="#0000aa">let</font><font color="#000000"> b-street-id </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">0</font><font color="#000000"> ?
        </font><font color="#0000aa">if</font><font color="#000000"> b-street-id </font><font color="#660096">!=</font><font color="#000000"> streetId
        [
          </font><font color="#0000aa">if</font><font color="#000000"> </font><font color="#660096">not</font><font color="#000000"> </font><font color="#660096">member?</font><font color="#000000"> b-street-id localStreets
          [
            </font><font color="#0000aa">set</font><font color="#000000"> localStreets </font><font color="#660096">lput</font><font color="#000000"> b-street-id localStreets
          ]
        ]
      ]
    ] 
    </font><font color="#5a5a5a">;set the globalStreets</font><font color="#000000">
    </font><font color="#0000aa">let</font><font color="#000000"> i </font><font color="#963700">0</font><font color="#000000"> 
    </font><font color="#0000aa">while</font><font color="#000000"> [i </font><font color="#660096">&lt;</font><font color="#000000"> (</font><font color="#660096">length</font><font color="#000000"> streetdata)]
    [
      </font><font color="#0000aa">if</font><font color="#000000"> i </font><font color="#660096">!=</font><font color="#000000"> streetId
      [
        </font><font color="#0000aa">if</font><font color="#000000"> </font><font color="#660096">not</font><font color="#000000"> </font><font color="#660096">member?</font><font color="#000000"> i localStreets
        [
          </font><font color="#0000aa">set</font><font color="#000000"> globalStreets </font><font color="#660096">lput</font><font color="#000000"> i globalStreets
        ]
      ]
      </font><font color="#0000aa">set</font><font color="#000000"> i i </font><font color="#660096">+</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000">
    ]
    </font><font color="#5a5a5a">;80 percent of probability to choose the next street within 3 steps from the origin</font><font color="#000000">
    </font><font color="#0000aa">let</font><font color="#000000"> p </font><font color="#660096">random-float</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000">              
    </font><font color="#0000aa">ifelse</font><font color="#000000"> p </font><font color="#660096">&lt;</font><font color="#000000"> </font><font color="#963700">0.8</font><font color="#000000">
    [
      </font><font color="#0000aa">let</font><font color="#000000"> nId </font><font color="#660096">random</font><font color="#000000"> </font><font color="#660096">length</font><font color="#000000"> localStreets
      </font><font color="#0000aa">let</font><font color="#000000"> nStreetId </font><font color="#660096">item</font><font color="#000000"> nId localStreets
      </font><font color="#0000aa">report</font><font color="#000000"> nStreetId
    ]
    [ 
      </font><font color="#0000aa">ifelse</font><font color="#000000"> </font><font color="#660096">not</font><font color="#000000"> </font><font color="#660096">empty?</font><font color="#000000"> globalStreets
      [
        </font><font color="#0000aa">let</font><font color="#000000"> nId </font><font color="#660096">random</font><font color="#000000"> </font><font color="#660096">length</font><font color="#000000"> globalStreets
        </font><font color="#0000aa">let</font><font color="#000000"> nStreetId </font><font color="#660096">item</font><font color="#000000"> nId globalStreets
        </font><font color="#0000aa">report</font><font color="#000000"> nStreetId
      ]
      [
        </font><font color="#0000aa">let</font><font color="#000000"> nId </font><font color="#660096">random</font><font color="#000000"> </font><font color="#660096">length</font><font color="#000000"> localStreets
        </font><font color="#0000aa">let</font><font color="#000000"> nStreetId </font><font color="#660096">item</font><font color="#000000"> nId localStreets
        </font><font color="#0000aa">report</font><font color="#000000"> nStreetId
      ]
    ]
  ]
</font><font color="#007f69">end</font><font color="#000000">
</font><font color="#5a5a5a">;Generate random agents</font><font color="#000000">
</font><font color="#007f69">to</font><font color="#000000"> GenerateRandomAgents
  create-people numOfAgents
  [
    </font><font color="#0000aa">let</font><font color="#000000"> streetId (</font><font color="#660096">random</font><font color="#000000"> </font><font color="#660096">length</font><font color="#000000"> streetdata)
    </font><font color="#5a5a5a">;let streetId random 425</font><font color="#000000">
    </font><font color="#0000aa">let</font><font color="#000000"> street </font><font color="#660096">item</font><font color="#000000"> streetId streetdata
    </font><font color="#0000aa">let</font><font color="#000000"> x1 </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">2</font><font color="#000000"> street
    </font><font color="#0000aa">let</font><font color="#000000"> y1 </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">3</font><font color="#000000"> street
    </font><font color="#0000aa">let</font><font color="#000000"> x2 </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">4</font><font color="#000000"> street
    </font><font color="#0000aa">let</font><font color="#000000"> y2 </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">5</font><font color="#000000"> street
    </font><font color="#0000aa">let</font><font color="#000000"> r1 </font><font color="#660096">random-float</font><font color="#000000"> </font><font color="#963700">1.0</font><font color="#000000">
    </font><font color="#0000aa">let</font><font color="#000000"> x (x1 </font><font color="#660096">+</font><font color="#000000"> (x2 </font><font color="#660096">-</font><font color="#000000"> x1)</font><font color="#660096">*</font><font color="#000000"> r1)
    </font><font color="#0000aa">let</font><font color="#000000"> y (y1 </font><font color="#660096">+</font><font color="#000000"> (y2 </font><font color="#660096">-</font><font color="#000000"> y1)</font><font color="#660096">*</font><font color="#000000"> r1)
    </font><font color="#0000aa">while</font><font color="#000000"> [</font><font color="#660096">any?</font><font color="#000000"> people-on </font><font color="#660096">patch</font><font color="#000000"> x y]
    [
      </font><font color="#0000aa">set</font><font color="#000000"> streetId (</font><font color="#660096">random</font><font color="#000000"> </font><font color="#660096">length</font><font color="#000000"> streetdata)
      </font><font color="#5a5a5a">;set streetId (random 425)</font><font color="#000000">
      </font><font color="#0000aa">set</font><font color="#000000"> street </font><font color="#660096">item</font><font color="#000000"> streetId streetdata
      </font><font color="#0000aa">set</font><font color="#000000"> x1 </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">2</font><font color="#000000"> street
      </font><font color="#0000aa">set</font><font color="#000000"> y1 </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">3</font><font color="#000000"> street
      </font><font color="#0000aa">set</font><font color="#000000"> x2 </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">4</font><font color="#000000"> street
      </font><font color="#0000aa">set</font><font color="#000000"> y2 </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">5</font><font color="#000000"> street
      </font><font color="#0000aa">set</font><font color="#000000"> r1 </font><font color="#660096">random-float</font><font color="#000000"> </font><font color="#963700">1.0</font><font color="#000000">
      </font><font color="#0000aa">set</font><font color="#000000"> x (x1 </font><font color="#660096">+</font><font color="#000000"> (x2 </font><font color="#660096">-</font><font color="#000000"> x1)</font><font color="#660096">*</font><font color="#000000"> r1)
      </font><font color="#0000aa">set</font><font color="#000000"> y (y1 </font><font color="#660096">+</font><font color="#000000"> (y2 </font><font color="#660096">-</font><font color="#000000"> y1)</font><font color="#660096">*</font><font color="#000000"> r1)
    ]
    </font><font color="#0000aa">setxy</font><font color="#000000"> x y
    </font><font color="#0000aa">set</font><font color="#000000"> </font><font color="#660096">size</font><font color="#000000"> agentSize
    </font><font color="#0000aa">set</font><font color="#000000"> </font><font color="#660096">color</font><font color="#000000"> </font><font color="#963700">blue</font><font color="#000000">
    </font><font color="#0000aa">set</font><font color="#000000"> </font><font color="#660096">shape</font><font color="#000000"> </font><font color="#963700">&quot;car top&quot;</font><font color="#000000">
    </font><font color="#0000aa">set</font><font color="#000000"> speed simulation-speed
    </font><font color="#0000aa">set</font><font color="#000000"> cur-street streetId
    </font><font color="#0000aa">set</font><font color="#000000"> last-street </font><font color="#963700">-1</font><font color="#000000">
    </font><font color="#0000aa">set</font><font color="#000000"> next-street </font><font color="#963700">-1</font><font color="#000000">
    </font><font color="#0000aa">set</font><font color="#000000"> cur-length </font><font color="#660096">sqrt</font><font color="#000000">((</font><font color="#660096">xcor</font><font color="#000000"> </font><font color="#660096">-</font><font color="#000000"> x1)</font><font color="#660096">*</font><font color="#000000">(</font><font color="#660096">xcor</font><font color="#000000"> </font><font color="#660096">-</font><font color="#000000"> x1)</font><font color="#660096">+</font><font color="#000000">(</font><font color="#660096">ycor</font><font color="#000000"> </font><font color="#660096">-</font><font color="#000000"> y1)</font><font color="#660096">*</font><font color="#000000">(</font><font color="#660096">ycor</font><font color="#000000"> </font><font color="#660096">-</font><font color="#000000"> y1))
    </font><font color="#0000aa">set</font><font color="#000000"> junc-length </font><font color="#963700">-1</font><font color="#000000">
    </font><font color="#0000aa">set</font><font color="#000000"> junc-point (</font><font color="#660096">list</font><font color="#000000">)
    </font><font color="#0000aa">set</font><font color="#000000"> last-location (</font><font color="#660096">list</font><font color="#000000">)
    </font><font color="#0000aa">set</font><font color="#000000"> direction </font><font color="#963700">0</font><font color="#000000">
    </font><font color="#0000aa">let</font><font color="#000000"> tracked </font><font color="#660096">item</font><font color="#000000"> streetId tracked-list
    </font><font color="#0000aa">set</font><font color="#000000"> tracked tracked </font><font color="#660096">+</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000">
    </font><font color="#0000aa">set</font><font color="#000000"> tracked-list </font><font color="#660096">replace-item</font><font color="#000000"> streetId tracked-list tracked
    </font><font color="#0000aa">let</font><font color="#000000"> visited </font><font color="#660096">item</font><font color="#000000"> streetId visited-list
    </font><font color="#0000aa">set</font><font color="#000000"> visited visited </font><font color="#660096">+</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000">
    </font><font color="#0000aa">set</font><font color="#000000"> visited-list </font><font color="#660096">replace-item</font><font color="#000000"> streetId visited-list visited
  ]
</font><font color="#007f69">end</font><font color="#000000">
</font><font color="#5a5a5a">;Set new destination for the purposive agent</font><font color="#000000">
</font><font color="#007f69">to</font><font color="#000000"> ResetDestination [who-num]
  </font><font color="#0000aa">let</font><font color="#000000"> xs [</font><font color="#660096">xcor</font><font color="#000000">]</font><font color="#660096">of</font><font color="#000000"> goalman who-num
  </font><font color="#0000aa">let</font><font color="#000000"> ys [</font><font color="#660096">ycor</font><font color="#000000">]</font><font color="#660096">of</font><font color="#000000"> goalman who-num
  </font><font color="#0000aa">let</font><font color="#000000"> streetIdF [last-street]</font><font color="#660096">of</font><font color="#000000"> goalman who-num
  </font><font color="#0000aa">let</font><font color="#000000"> l </font><font color="#963700">-1</font><font color="#000000">
  </font><font color="#5a5a5a">;Purposive walker bahavior</font><font color="#000000">
  </font><font color="#0000aa">let</font><font color="#000000"> streetIdT Purposive_walker_behavior streetIdF
  </font><font color="#0000aa">let</font><font color="#000000"> streetT </font><font color="#660096">item</font><font color="#000000"> streetIdT streetdata
  </font><font color="#0000aa">let</font><font color="#000000"> x3 </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">2</font><font color="#000000"> streetT
  </font><font color="#0000aa">let</font><font color="#000000"> y3 </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">3</font><font color="#000000"> streetT
  </font><font color="#0000aa">let</font><font color="#000000"> x4 </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">4</font><font color="#000000"> streetT
  </font><font color="#0000aa">let</font><font color="#000000"> y4 </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">5</font><font color="#000000"> streetT
  </font><font color="#0000aa">let</font><font color="#000000"> r1 </font><font color="#660096">random-float</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000">
  </font><font color="#0000aa">let</font><font color="#000000"> xt (x3 </font><font color="#660096">+</font><font color="#000000"> (x4 </font><font color="#660096">-</font><font color="#000000"> x3)</font><font color="#660096">*</font><font color="#000000"> r1)
  </font><font color="#0000aa">let</font><font color="#000000"> yt (y3 </font><font color="#660096">+</font><font color="#000000"> (y4 </font><font color="#660096">-</font><font color="#000000"> y3)</font><font color="#660096">*</font><font color="#000000"> r1)
  </font><font color="#5a5a5a">;calculate the shortest path  </font><font color="#000000">
  </font><font color="#0000aa">let</font><font color="#000000"> myGoalPaths GetPath xs ys streetIdF xt yt streetIdT
  </font><font color="#5a5a5a">;rectify the shortest path by reomoving the trivial segment</font><font color="#000000">
  </font><font color="#0000aa">let</font><font color="#000000"> RectifyGoalPaths (</font><font color="#660096">list</font><font color="#000000">)
  </font><font color="#0000aa">foreach</font><font color="#000000"> myGoalPaths
  [
    </font><font color="#0000aa">let</font><font color="#000000"> path-ele ?
    </font><font color="#0000aa">ifelse</font><font color="#000000"> </font><font color="#660096">is-list?</font><font color="#000000"> path-ele
    [
      </font><font color="#0000aa">let</font><font color="#000000"> x1 </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000"> path-ele
      </font><font color="#0000aa">let</font><font color="#000000"> y1 </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">2</font><font color="#000000"> path-ele
      </font><font color="#0000aa">let</font><font color="#000000"> x2 </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">3</font><font color="#000000"> path-ele
      </font><font color="#0000aa">let</font><font color="#000000"> y2 </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">4</font><font color="#000000"> path-ele
      
      </font><font color="#0000aa">ifelse</font><font color="#000000"> (</font><font color="#660096">abs</font><font color="#000000">(x1 </font><font color="#660096">-</font><font color="#000000"> x2)</font><font color="#660096">&lt;</font><font color="#000000"> </font><font color="#963700">0.00001</font><font color="#000000">)</font><font color="#660096">and</font><font color="#000000">(</font><font color="#660096">abs</font><font color="#000000">(y1 </font><font color="#660096">-</font><font color="#000000"> y2)</font><font color="#660096">&lt;</font><font color="#000000"> </font><font color="#963700">0.00001</font><font color="#000000">)
      [
        </font><font color="#5a5a5a">;delete this path segment</font><font color="#000000">
      ]
      [
        </font><font color="#0000aa">set</font><font color="#000000"> RectifyGoalPaths </font><font color="#660096">lput</font><font color="#000000"> path-ele RectifyGoalPaths
      ]
    ]
    [
      </font><font color="#0000aa">set</font><font color="#000000"> RectifyGoalPaths </font><font color="#660096">lput</font><font color="#000000"> path-ele RectifyGoalPaths
    ]
  ]
  </font><font color="#5a5a5a">;ifelse length RectifyGoalPaths &gt; 1</font><font color="#000000">
  </font><font color="#0000aa">ifelse</font><font color="#000000"> </font><font color="#660096">length</font><font color="#000000"> RectifyGoalPaths </font><font color="#660096">&gt;</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000">
  [
    </font><font color="#0000aa">ask</font><font color="#000000"> goalman who-num
    [
      </font><font color="#0000aa">let</font><font color="#000000"> firstPathSeg </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000"> RectifyGoalPaths
      </font><font color="#0000aa">set</font><font color="#000000"> cur-street (</font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">0</font><font color="#000000"> firstPathSeg)
      </font><font color="#0000aa">set</font><font color="#000000"> last-street </font><font color="#963700">-1</font><font color="#000000">
      </font><font color="#0000aa">set</font><font color="#000000"> next-street </font><font color="#963700">-1</font><font color="#000000">
      </font><font color="#0000aa">set</font><font color="#000000"> cur-length distanceToFrom cur-street (</font><font color="#660096">list</font><font color="#000000"> </font><font color="#660096">xcor</font><font color="#000000"> </font><font color="#660096">ycor</font><font color="#000000">)
      </font><font color="#0000aa">set</font><font color="#000000"> junc-length </font><font color="#963700">-1</font><font color="#000000">
      </font><font color="#0000aa">set</font><font color="#000000"> junc-point (</font><font color="#660096">list</font><font color="#000000">)
      </font><font color="#0000aa">set</font><font color="#000000"> last-location (</font><font color="#660096">list</font><font color="#000000">)
      </font><font color="#0000aa">set</font><font color="#000000"> direction </font><font color="#963700">0</font><font color="#000000">
      </font><font color="#0000aa">set</font><font color="#000000"> dest-street streetIdT
      </font><font color="#0000aa">set</font><font color="#000000"> dest-x xt
      </font><font color="#0000aa">set</font><font color="#000000"> dest-y yt
      </font><font color="#0000aa">set</font><font color="#000000"> path-goal RectifyGoalPaths
      </font><font color="#0000aa">set</font><font color="#000000"> speed simulation-speed
    ]
    
    </font><font color="#0000aa">let</font><font color="#000000"> tracked </font><font color="#660096">item</font><font color="#000000"> streetIdF tracked-goal-list
    </font><font color="#0000aa">set</font><font color="#000000"> tracked tracked </font><font color="#660096">+</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000">
    </font><font color="#0000aa">set</font><font color="#000000"> tracked-goal-list </font><font color="#660096">replace-item</font><font color="#000000"> streetIdF tracked-goal-list tracked
    
    </font><font color="#0000aa">let</font><font color="#000000"> visited </font><font color="#660096">item</font><font color="#000000"> streetIdT visited-goal-list
    </font><font color="#0000aa">set</font><font color="#000000"> visited visited </font><font color="#660096">+</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000">
    </font><font color="#0000aa">set</font><font color="#000000"> visited-goal-list </font><font color="#660096">replace-item</font><font color="#000000"> streetIdT visited-goal-list visited
  ]
  [
    ResetDestination who-num
  ]
</font><font color="#007f69">end</font><font color="#000000">
</font><font color="#5a5a5a">;Go Once Procedure</font><font color="#000000">
</font><font color="#007f69">to</font><font color="#000000"> GoOnce
  </font><font color="#0000aa">ifelse</font><font color="#000000"> MovingBehavior </font><font color="#660096">=</font><font color="#000000"> </font><font color="#963700">&quot;Random&quot;</font><font color="#000000">
  [
    </font><font color="#0000aa">ask</font><font color="#000000"> people
    [
      move-agents-random </font><font color="#660096">who</font><font color="#000000">
    ]
  ]
  [
    </font><font color="#0000aa">ask</font><font color="#000000"> goalmen
    [ 
      move-agents-purposive </font><font color="#660096">who</font><font color="#000000">
    ] 
  ]
  </font><font color="#0000aa">tick</font><font color="#000000">
  myPlot
</font><font color="#007f69">end</font><font color="#000000">
</font><font color="#5a5a5a">;Go procedure</font><font color="#000000">
</font><font color="#007f69">to</font><font color="#000000"> Go
  </font><font color="#0000aa">ifelse</font><font color="#000000"> MovingBehavior </font><font color="#660096">=</font><font color="#000000"> </font><font color="#963700">&quot;Random&quot;</font><font color="#000000">
  [
    </font><font color="#0000aa">ask</font><font color="#000000"> people
    [
      move-agents-random </font><font color="#660096">who</font><font color="#000000">
    ]
  ]
  [
    </font><font color="#0000aa">ask</font><font color="#000000"> goalmen
    [ 
      move-agents-purposive </font><font color="#660096">who</font><font color="#000000">
    ] 
  ]
  </font><font color="#0000aa">tick</font><font color="#000000">
  </font><font color="#5a5a5a">; to plot the flow every 100 tick</font><font color="#000000">
</font><font color="#5a5a5a">;  let mycount (floor ticks / 100)</font><font color="#000000">
</font><font color="#5a5a5a">;  if mycount = printTime</font><font color="#000000">
</font><font color="#5a5a5a">;  [</font><font color="#000000">
</font><font color="#5a5a5a">;    let tracked-quarter-list (list)</font><font color="#000000">
</font><font color="#5a5a5a">;    ifelse MovingBehavior = &quot;Random&quot;</font><font color="#000000">
</font><font color="#5a5a5a">;    [</font><font color="#000000">
</font><font color="#5a5a5a">;      set tracked-quarter-list map [? ^ 0.25] tracked-list</font><font color="#000000">
</font><font color="#5a5a5a">;    ]</font><font color="#000000">
</font><font color="#5a5a5a">;    [</font><font color="#000000">
</font><font color="#5a5a5a">;      set tracked-quarter-list map [? ^ 0.25] tracked-goal-list</font><font color="#000000">
</font><font color="#5a5a5a">;    ]</font><font color="#000000">
</font><font color="#5a5a5a">;    let rs calculateRS wpr-list tracked-quarter-list</font><font color="#000000">
</font><font color="#5a5a5a">;    set time-series lput printTime (but-first time-series)</font><font color="#000000">
</font><font color="#5a5a5a">;    set wpr-rs-list lput rs wpr-rs-list</font><font color="#000000">
</font><font color="#5a5a5a">;    set printTime printTime + 1</font><font color="#000000">
</font><font color="#5a5a5a">;  ]</font><font color="#000000">
  myPlot
</font><font color="#007f69">end</font><font color="#000000">
</font><font color="#5a5a5a">;Calculate the R Square vlue between two variables</font><font color="#000000">
</font><font color="#007f69">to-report</font><font color="#000000"> calculateRS [varlist1 varlist2]
  </font><font color="#0000aa">let</font><font color="#000000"> EvarList1 </font><font color="#660096">mean</font><font color="#000000"> varlist1
  </font><font color="#0000aa">let</font><font color="#000000"> EvarList2 </font><font color="#660096">mean</font><font color="#000000"> varlist2
  </font><font color="#0000aa">set</font><font color="#000000"> f </font><font color="#660096">length</font><font color="#000000"> varlist1 
  </font><font color="#0000aa">set</font><font color="#000000"> g </font><font color="#660096">length</font><font color="#000000"> varlist2
  </font><font color="#0000aa">let</font><font color="#000000"> crossproduct (</font><font color="#660096">map</font><font color="#000000"> [?1 </font><font color="#660096">*</font><font color="#000000"> ?2] varlist1 varlist2)
  </font><font color="#0000aa">let</font><font color="#000000"> ECrossProduct </font><font color="#660096">mean</font><font color="#000000"> crossproduct
  </font><font color="#0000aa">let</font><font color="#000000"> std1 </font><font color="#660096">standard-deviation</font><font color="#000000"> varlist1
  </font><font color="#0000aa">let</font><font color="#000000"> std2 </font><font color="#660096">standard-deviation</font><font color="#000000"> varlist2
  </font><font color="#0000aa">let</font><font color="#000000"> myLen </font><font color="#660096">length</font><font color="#000000"> varlist1
  </font><font color="#0000aa">set</font><font color="#000000"> std1 std1 </font><font color="#660096">*</font><font color="#000000"> </font><font color="#660096">sqrt</font><font color="#000000">((myLen </font><font color="#660096">-</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000">)</font><font color="#660096">/</font><font color="#000000"> myLen)
  </font><font color="#0000aa">set</font><font color="#000000"> std2 std2 </font><font color="#660096">*</font><font color="#000000"> </font><font color="#660096">sqrt</font><font color="#000000">((myLen </font><font color="#660096">-</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000">)</font><font color="#660096">/</font><font color="#000000"> myLen) 
  </font><font color="#0000aa">let</font><font color="#000000"> rs </font><font color="#963700">0</font><font color="#000000">
  </font><font color="#0000aa">if</font><font color="#000000"> std1 </font><font color="#660096">!=</font><font color="#000000"> </font><font color="#963700">0</font><font color="#000000"> </font><font color="#660096">and</font><font color="#000000"> std2 </font><font color="#660096">!=</font><font color="#000000"> </font><font color="#963700">0</font><font color="#000000">
  [
    </font><font color="#0000aa">set</font><font color="#000000"> rs (ECrossProduct </font><font color="#660096">-</font><font color="#000000"> EvarList1 </font><font color="#660096">*</font><font color="#000000"> EvarList2)</font><font color="#660096">/</font><font color="#000000">(std1 </font><font color="#660096">*</font><font color="#000000"> std2)
    </font><font color="#0000aa">set</font><font color="#000000"> rs rs </font><font color="#660096">*</font><font color="#000000"> rs
  ]
  </font><font color="#0000aa">report</font><font color="#000000"> rs
</font><font color="#007f69">end</font><font color="#000000">
</font><font color="#5a5a5a">;plot the mean velocity, maximum velocity, and minimum velocity</font><font color="#000000">
</font><font color="#007f69">to</font><font color="#000000"> myPlot
  </font><font color="#5a5a5a">;plot the traffic flow distribution</font><font color="#000000">
  </font><font color="#0000aa">let</font><font color="#000000"> trafficFlow-list (</font><font color="#660096">list</font><font color="#000000">)
  </font><font color="#0000aa">ifelse</font><font color="#000000"> MovingBehavior </font><font color="#660096">=</font><font color="#000000"> </font><font color="#963700">&quot;Random&quot;</font><font color="#000000">
  [
    </font><font color="#0000aa">set</font><font color="#000000"> trafficFlow-list tracked-list  
  ]
  [
    </font><font color="#0000aa">set</font><font color="#000000"> trafficFlow-list tracked-goal-list
  ]
  </font><font color="#5a5a5a">;plot the power law distribution of Traffic flow</font><font color="#000000">
  </font><font color="#0000aa">set-current-plot</font><font color="#000000"> </font><font color="#963700">&quot;Power law distribution of Traffic flow&quot;</font><font color="#000000">
  </font><font color="#0000aa">clear-plot</font><font color="#000000">
  </font><font color="#0000aa">let</font><font color="#000000"> log-histogram </font><font color="#660096">n-values</font><font color="#000000"> ((</font><font color="#660096">max</font><font color="#000000"> trafficFlow-list) </font><font color="#660096">+</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000">) [</font><font color="#963700">0</font><font color="#000000">] 
  </font><font color="#0000aa">let</font><font color="#000000"> min1 (</font><font color="#660096">min</font><font color="#000000"> trafficFlow-list)
  </font><font color="#0000aa">foreach</font><font color="#000000"> trafficFlow-list 
  [  
    </font><font color="#0000aa">let</font><font color="#000000"> old-value </font><font color="#660096">item</font><font color="#000000"> ? log-histogram
    </font><font color="#0000aa">set</font><font color="#000000"> log-histogram </font><font color="#660096">replace-item</font><font color="#000000"> ? log-histogram (old-value </font><font color="#660096">+</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000">)
  ]
  
  </font><font color="#0000aa">let</font><font color="#000000"> tracked-list-new </font><font color="#660096">sort</font><font color="#000000"> trafficFlow-list
  </font><font color="#0000aa">set</font><font color="#000000"> tracked-list-new </font><font color="#660096">remove-duplicates</font><font color="#000000"> tracked-list-new
  </font><font color="#0000aa">let</font><font color="#000000"> tracked-list-new-rectify (</font><font color="#660096">list</font><font color="#000000">)
  </font><font color="#0000aa">set</font><font color="#000000"> d </font><font color="#660096">length</font><font color="#000000"> tracked-list-new
  </font><font color="#0000aa">foreach</font><font color="#000000"> tracked-list-new
  [
    </font><font color="#0000aa">let</font><font color="#000000"> a-value ?
    </font><font color="#0000aa">set</font><font color="#000000"> a-value (</font><font color="#963700">99</font><font color="#000000"> </font><font color="#660096">*</font><font color="#000000"> (a-value </font><font color="#660096">-</font><font color="#000000"> (</font><font color="#660096">min</font><font color="#000000"> tracked-list-new)) </font><font color="#660096">/</font><font color="#000000"> ((</font><font color="#660096">max</font><font color="#000000"> tracked-list-new) </font><font color="#660096">-</font><font color="#000000"> (</font><font color="#660096">min</font><font color="#000000"> tracked-list-new))) </font><font color="#660096">+</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000">
    </font><font color="#0000aa">set</font><font color="#000000"> tracked-list-new-rectify </font><font color="#660096">lput</font><font color="#000000"> a-value tracked-list-new-rectify
  ]  
  </font><font color="#0000aa">let</font><font color="#000000"> log-histogram-1 (</font><font color="#660096">list</font><font color="#000000">)
  </font><font color="#0000aa">foreach</font><font color="#000000"> log-histogram
  [
     </font><font color="#0000aa">if</font><font color="#000000"> ? </font><font color="#660096">&gt;</font><font color="#000000"> </font><font color="#963700">0</font><font color="#000000">
     [
       </font><font color="#0000aa">set</font><font color="#000000"> log-histogram-1 </font><font color="#660096">lput</font><font color="#000000"> ? log-histogram-1
     ]
  ]
  </font><font color="#0000aa">let</font><font color="#000000"> totalNum </font><font color="#660096">sum</font><font color="#000000"> log-histogram-1
  </font><font color="#0000aa">let</font><font color="#000000"> log-histogram-2 (</font><font color="#660096">list</font><font color="#000000">)
  </font><font color="#0000aa">foreach</font><font color="#000000"> log-histogram-1
  [
    </font><font color="#0000aa">let</font><font color="#000000"> percentage (? </font><font color="#660096">/</font><font color="#000000"> totalNum)
    </font><font color="#0000aa">set</font><font color="#000000"> log-histogram-2 </font><font color="#660096">lput</font><font color="#000000"> percentage log-histogram-2
  ]
  </font><font color="#0000aa">let</font><font color="#000000"> index </font><font color="#963700">0</font><font color="#000000">
  </font><font color="#0000aa">let</font><font color="#000000"> log-histogram-rectify (</font><font color="#660096">list</font><font color="#000000">)
  </font><font color="#0000aa">while</font><font color="#000000"> [index </font><font color="#660096">&lt;</font><font color="#000000"> </font><font color="#660096">length</font><font color="#000000"> log-histogram-2]
  [
    </font><font color="#0000aa">let</font><font color="#000000"> index1 index
    </font><font color="#0000aa">let</font><font color="#000000"> eleSum </font><font color="#963700">0</font><font color="#000000">
    </font><font color="#0000aa">while</font><font color="#000000"> [index1 </font><font color="#660096">&lt;</font><font color="#000000"> </font><font color="#660096">length</font><font color="#000000"> log-histogram-2]
    [
      </font><font color="#0000aa">let</font><font color="#000000"> ele </font><font color="#660096">item</font><font color="#000000"> index1 log-histogram-2
      </font><font color="#0000aa">set</font><font color="#000000"> eleSum eleSum </font><font color="#660096">+</font><font color="#000000"> ele
      </font><font color="#0000aa">set</font><font color="#000000"> index1 index1 </font><font color="#660096">+</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000">
    ]
    </font><font color="#0000aa">set</font><font color="#000000"> log-histogram-rectify </font><font color="#660096">lput</font><font color="#000000"> eleSum log-histogram-rectify
    </font><font color="#0000aa">set</font><font color="#000000"> index index </font><font color="#660096">+</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000">
  ]
  </font><font color="#0000aa">ifelse</font><font color="#000000"> (</font><font color="#660096">length</font><font color="#000000"> log-histogram-rectify) </font><font color="#660096">=</font><font color="#000000"> (</font><font color="#660096">length</font><font color="#000000"> tracked-list-new-rectify)
  [
    </font><font color="#0000aa">set-plot-y-range</font><font color="#000000"> (</font><font color="#660096">precision</font><font color="#000000">(</font><font color="#660096">log</font><font color="#000000">(</font><font color="#660096">min</font><font color="#000000"> log-histogram-rectify)</font><font color="#963700">10</font><font color="#000000">)</font><font color="#963700">2</font><font color="#000000">) </font><font color="#963700">0.01</font><font color="#000000">    
    (</font><font color="#0000aa">foreach</font><font color="#000000"> tracked-list-new-rectify log-histogram-rectify
    [
      </font><font color="#0000aa">plotxy</font><font color="#000000"> (</font><font color="#660096">log</font><font color="#000000"> ?1 </font><font color="#963700">10</font><font color="#000000">)(</font><font color="#660096">log</font><font color="#000000"> ?2 </font><font color="#963700">10</font><font color="#000000">)
    ])
  ]
  [
    </font><font color="#0000aa">user-message</font><font color="#000000"> </font><font color="#963700">&quot;error in plot!&quot;</font><font color="#000000">
  ]
</font><font color="#5a5a5a">;  ifelse sliding-plot?</font><font color="#000000">
</font><font color="#5a5a5a">;  [</font><font color="#000000">
</font><font color="#5a5a5a">;    ;plot the R square value of traffic flow and wpr value</font><font color="#000000">
</font><font color="#5a5a5a">;    if not empty? wpr-rs-list</font><font color="#000000">
</font><font color="#5a5a5a">;    [</font><font color="#000000">
</font><font color="#5a5a5a">;      set-current-plot &quot;trafficFlow-vs-Wpr&quot;</font><font color="#000000">
</font><font color="#5a5a5a">;      clear-plot</font><font color="#000000">
</font><font color="#5a5a5a">;      set-plot-pen-mode 2</font><font color="#000000">
</font><font color="#5a5a5a">;      auto-plot-off</font><font color="#000000">
</font><font color="#5a5a5a">;      set-plot-x-range (first time-series) (last time-series)</font><font color="#000000">
</font><font color="#5a5a5a">;      set-plot-y-range 0 1</font><font color="#000000">
</font><font color="#5a5a5a">;      let wpr-rs-list-plot (list)</font><font color="#000000">
</font><font color="#5a5a5a">;      ifelse (length wpr-rs-list)&gt;= 10</font><font color="#000000">
</font><font color="#5a5a5a">;      [</font><font color="#000000">
</font><font color="#5a5a5a">;        set wpr-rs-list-plot sublist wpr-rs-list (printTime - 11) (printTime - 1)</font><font color="#000000">
</font><font color="#5a5a5a">;      ]</font><font color="#000000">
</font><font color="#5a5a5a">;      [</font><font color="#000000">
</font><font color="#5a5a5a">;        foreach wpr-rs-list</font><font color="#000000">
</font><font color="#5a5a5a">;        [</font><font color="#000000">
</font><font color="#5a5a5a">;          set wpr-rs-list-plot lput ? wpr-rs-list-plot</font><font color="#000000">
</font><font color="#5a5a5a">;        ]</font><font color="#000000">
</font><font color="#5a5a5a">;        while [(length wpr-rs-list-plot)&lt; 10]</font><font color="#000000">
</font><font color="#5a5a5a">;        [</font><font color="#000000">
</font><font color="#5a5a5a">;          set wpr-rs-list-plot fput 0 wpr-rs-list-plot</font><font color="#000000">
</font><font color="#5a5a5a">;        ]</font><font color="#000000">
</font><font color="#5a5a5a">;      ]</font><font color="#000000">
</font><font color="#5a5a5a">;      (foreach wpr-rs-list-plot time-series</font><font color="#000000">
</font><font color="#5a5a5a">;      [</font><font color="#000000">
</font><font color="#5a5a5a">;        plotxy ?2 ?1</font><font color="#000000">
</font><font color="#5a5a5a">;      ])</font><font color="#000000">
</font><font color="#5a5a5a">;    ]</font><font color="#000000">
</font><font color="#5a5a5a">;  ]</font><font color="#000000">
</font><font color="#5a5a5a">;  [</font><font color="#000000">
</font><font color="#5a5a5a">;    ;plot the R square value of traffic flow and wpr value</font><font color="#000000">
</font><font color="#5a5a5a">;    if not empty? wpr-rs-list</font><font color="#000000">
</font><font color="#5a5a5a">;    [</font><font color="#000000">
</font><font color="#5a5a5a">;      set-current-plot &quot;trafficFlow-vs-Wpr&quot;</font><font color="#000000">
</font><font color="#5a5a5a">;      clear-plot</font><font color="#000000">
</font><font color="#5a5a5a">;      set-plot-pen-mode 2</font><font color="#000000">
</font><font color="#5a5a5a">;      auto-plot-on</font><font color="#000000">
</font><font color="#5a5a5a">;      let j 1</font><font color="#000000">
</font><font color="#5a5a5a">;      foreach wpr-rs-list</font><font color="#000000">
</font><font color="#5a5a5a">;      [</font><font color="#000000">
</font><font color="#5a5a5a">;        plotxy j ?</font><font color="#000000">
</font><font color="#5a5a5a">;        set j j + 1</font><font color="#000000">
</font><font color="#5a5a5a">;      ]</font><font color="#000000">
</font><font color="#5a5a5a">;    ]</font><font color="#000000">
</font><font color="#5a5a5a">;  ]</font><font color="#000000">
  </font><font color="#5a5a5a">;plot the R square value of traffic flow and wpr value</font><font color="#000000">
  </font><font color="#0000aa">set-current-plot</font><font color="#000000"> </font><font color="#963700">&quot;Correlation between Traffic flow and Metric&quot;</font><font color="#000000">
  </font><font color="#0000aa">clear-plot</font><font color="#000000">
  </font><font color="#0000aa">set-plot-pen-mode</font><font color="#000000"> </font><font color="#963700">2</font><font color="#000000">
  </font><font color="#0000aa">auto-plot-on</font><font color="#000000">
  
  </font><font color="#0000aa">let</font><font color="#000000"> minFlow (</font><font color="#660096">min</font><font color="#000000"> trafficFlow-list)
  </font><font color="#0000aa">let</font><font color="#000000"> maxFlow (</font><font color="#660096">max</font><font color="#000000"> trafficFlow-list)
  </font><font color="#0000aa">ifelse</font><font color="#000000"> MovingBehavior </font><font color="#660096">=</font><font color="#000000"> </font><font color="#963700">&quot;Random&quot;</font><font color="#000000">
  [ 
    </font><font color="#5a5a5a">; let trafficFlow-wpr-list (list)</font><font color="#000000">
     </font><font color="#0000aa">let</font><font color="#000000"> trafficFlow-cnt-list (</font><font color="#660096">list</font><font color="#000000">)
      </font><font color="#5a5a5a">;set c length wlist</font><font color="#000000">
      </font><font color="#5a5a5a">;set d length trafficFlow-list</font><font color="#000000">
    (</font><font color="#5a5a5a">;foreach trafficFlow-list wpr-list</font><font color="#000000">
      </font><font color="#5a5a5a">; foreach trafficFlow-list wlist</font><font color="#000000">
      </font><font color="#0000aa">foreach</font><font color="#000000"> trafficFlow-list connect-list
      [
        </font><font color="#5a5a5a">;set trafficFlow-wpr-list lput (list ((99 * (?1 - minFlow) / (maxFlow - minFlow)) + 1) ?2) trafficFlow-wpr-list</font><font color="#000000">
        </font><font color="#0000aa">if</font><font color="#000000"> ?1 </font><font color="#660096">&gt;</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000">
        [
         </font><font color="#5a5a5a">; set trafficFlow-wpr-list lput (list ?1 ?2) trafficFlow-wpr-list</font><font color="#000000">
         </font><font color="#0000aa">set</font><font color="#000000"> trafficFlow-cnt-list </font><font color="#660096">lput</font><font color="#000000"> (</font><font color="#660096">list</font><font color="#000000"> ?1 ?2) trafficFlow-cnt-list
        ]
      ])
    </font><font color="#5a5a5a">; set trafficFlow-wpr-list sort-by [(item 0 ?1)&lt;(item 0 ?2)] trafficFlow-wpr-list</font><font color="#000000">
    </font><font color="#0000aa">set</font><font color="#000000"> trafficFlow-cnt-list </font><font color="#660096">sort-by</font><font color="#000000"> [(</font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">0</font><font color="#000000"> ?1)</font><font color="#660096">&lt;</font><font color="#000000">(</font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">0</font><font color="#000000"> ?2)] trafficFlow-cnt-list
    </font><font color="#5a5a5a">; foreach trafficFlow-wpr-list</font><font color="#000000">
    </font><font color="#0000aa">foreach</font><font color="#000000"> trafficFlow-cnt-list
    [
      </font><font color="#0000aa">plotxy</font><font color="#000000"> (</font><font color="#660096">log</font><font color="#000000">(</font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">0</font><font color="#000000"> ?)</font><font color="#963700">10</font><font color="#000000">) (</font><font color="#660096">log</font><font color="#000000">(</font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000"> ?)</font><font color="#963700">10</font><font color="#000000">)
      </font><font color="#5a5a5a">;plotxy ((item 0 ?)^ 0.25) ((item 1 ?)^ 0.25)</font><font color="#000000">
    ]
    </font><font color="#0000aa">let</font><font color="#000000"> trafficFlow-list-quarter </font><font color="#660096">map</font><font color="#000000"> [? </font><font color="#660096">^</font><font color="#000000"> </font><font color="#963700">0.25</font><font color="#000000">] trafficFlow-list
    </font><font color="#5a5a5a">;let wpr-list-quarter map [? ^ 0.25] wpr-list</font><font color="#000000">
    </font><font color="#5a5a5a">;let wpr-list-quarter map [? ^ 0.25] wlist</font><font color="#000000">
    </font><font color="#0000aa">let</font><font color="#000000"> cnt-list-quarter </font><font color="#660096">map</font><font color="#000000"> [? </font><font color="#660096">^</font><font color="#000000"> </font><font color="#963700">0.25</font><font color="#000000">] connect-list
    </font><font color="#5a5a5a">;fixed precision for number</font><font color="#000000">
   </font><font color="#5a5a5a">; let rSquare-str (word calculateRS wpr-list-quarter trafficFlow-list-quarter)</font><font color="#000000">
    </font><font color="#0000aa">let</font><font color="#000000"> rSquare-str (</font><font color="#660096">word</font><font color="#000000"> calculateRS cnt-list-quarter trafficFlow-list-quarter)
    </font><font color="#0000aa">while</font><font color="#000000"> [(</font><font color="#660096">length</font><font color="#000000"> rSquare-str)</font><font color="#660096">&lt;</font><font color="#000000"> </font><font color="#963700">7</font><font color="#000000">]
    [
      </font><font color="#0000aa">set</font><font color="#000000"> rSquare-str (</font><font color="#660096">word</font><font color="#000000"> rSquare-str </font><font color="#963700">0</font><font color="#000000">)
    ]
    </font><font color="#0000aa">set</font><font color="#000000"> rSquare-str (</font><font color="#660096">substring</font><font color="#000000"> rSquare-str </font><font color="#963700">0</font><font color="#000000"> </font><font color="#963700">7</font><font color="#000000">)
    </font><font color="#0000aa">set</font><font color="#000000"> R-Square rSquare-str
    </font><font color="#5a5a5a">;set R-square precision (calculateRS wpr-list-quarter trafficFlow-list-quarter) 5</font><font color="#000000">
  ]
  [
     </font><font color="#0000aa">let</font><font color="#000000"> trafficFlow-ltg-list (</font><font color="#660096">list</font><font color="#000000">)
     
    (</font><font color="#5a5a5a">;foreach trafficFlow-list wpr-list</font><font color="#000000">
      </font><font color="#5a5a5a">; foreach trafficFlow-list wlist</font><font color="#000000">
      </font><font color="#0000aa">foreach</font><font color="#000000"> trafficFlow-list ltg-list
      [
        </font><font color="#5a5a5a">;set trafficFlow-wpr-list lput (list ((99 * (?1 - minFlow) / (maxFlow - minFlow)) + 1) ?2) trafficFlow-wpr-list</font><font color="#000000">
        </font><font color="#0000aa">if</font><font color="#000000"> ?1 </font><font color="#660096">&gt;</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000">
        [
         </font><font color="#5a5a5a">; set trafficFlow-wpr-list lput (list ?1 ?2) trafficFlow-wpr-list</font><font color="#000000">
         </font><font color="#0000aa">set</font><font color="#000000"> trafficFlow-ltg-list </font><font color="#660096">lput</font><font color="#000000"> (</font><font color="#660096">list</font><font color="#000000"> ?1 ?2) trafficFlow-ltg-list
        ]
      ])
    </font><font color="#5a5a5a">; set trafficFlow-wpr-list sort-by [(item 0 ?1)&lt;(item 0 ?2)] trafficFlow-wpr-list</font><font color="#000000">
    </font><font color="#0000aa">set</font><font color="#000000"> trafficFlow-ltg-list </font><font color="#660096">sort-by</font><font color="#000000"> [(</font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">0</font><font color="#000000"> ?1)</font><font color="#660096">&lt;</font><font color="#000000">(</font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">0</font><font color="#000000"> ?2)] trafficFlow-ltg-list
    </font><font color="#5a5a5a">; foreach trafficFlow-wpr-list</font><font color="#000000">
    </font><font color="#0000aa">foreach</font><font color="#000000"> trafficFlow-ltg-list
    [
      </font><font color="#0000aa">plotxy</font><font color="#000000"> (</font><font color="#660096">log</font><font color="#000000">(</font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">0</font><font color="#000000"> ?)</font><font color="#963700">10</font><font color="#000000">) (</font><font color="#660096">log</font><font color="#000000">(</font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000"> ?)</font><font color="#963700">10</font><font color="#000000">)
      </font><font color="#5a5a5a">;plotxy ((item 0 ?)^ 0.25) ((item 1 ?)^ 0.25)</font><font color="#000000">
    ]
    </font><font color="#0000aa">let</font><font color="#000000"> trafficFlow-list-quarter </font><font color="#660096">map</font><font color="#000000"> [? </font><font color="#660096">^</font><font color="#000000"> </font><font color="#963700">0.25</font><font color="#000000">] trafficFlow-list
    </font><font color="#5a5a5a">;let wpr-list-quarter map [? ^ 0.25] wpr-list</font><font color="#000000">
    </font><font color="#5a5a5a">;let wpr-list-quarter map [? ^ 0.25] wlist</font><font color="#000000">
    </font><font color="#0000aa">let</font><font color="#000000"> ltg-list-quarter </font><font color="#660096">map</font><font color="#000000"> [? </font><font color="#660096">^</font><font color="#000000"> </font><font color="#963700">0.25</font><font color="#000000">] ltg-list
    </font><font color="#5a5a5a">;fixed precision for number</font><font color="#000000">
   </font><font color="#5a5a5a">; let rSquare-str (word calculateRS wpr-list-quarter trafficFlow-list-quarter)</font><font color="#000000">
    </font><font color="#0000aa">let</font><font color="#000000"> rSquare-str (</font><font color="#660096">word</font><font color="#000000"> calculateRS ltg-list-quarter trafficFlow-list-quarter)
    </font><font color="#0000aa">while</font><font color="#000000"> [(</font><font color="#660096">length</font><font color="#000000"> rSquare-str)</font><font color="#660096">&lt;</font><font color="#000000"> </font><font color="#963700">7</font><font color="#000000">]
    [
      </font><font color="#0000aa">set</font><font color="#000000"> rSquare-str (</font><font color="#660096">word</font><font color="#000000"> rSquare-str </font><font color="#963700">0</font><font color="#000000">)
    ]
    </font><font color="#0000aa">set</font><font color="#000000"> rSquare-str (</font><font color="#660096">substring</font><font color="#000000"> rSquare-str </font><font color="#963700">0</font><font color="#000000"> </font><font color="#963700">7</font><font color="#000000">)
    </font><font color="#0000aa">set</font><font color="#000000"> R-Square rSquare-str
         
   </font><font color="#5a5a5a">; let trafficFlow-betweeness-list (list)</font><font color="#000000">
    </font><font color="#5a5a5a">;     set a length trafficFlow-list</font><font color="#000000">
   </font><font color="#5a5a5a">;      set b length blist</font><font color="#000000">
  </font><font color="#5a5a5a">;  (;foreach trafficFlow-list betweeness-list</font><font color="#000000">
   </font><font color="#5a5a5a">;   foreach trafficFlow-list blist   </font><font color="#000000">
  </font><font color="#5a5a5a">;    [</font><font color="#000000">
        </font><font color="#5a5a5a">;set trafficFlow-wpr-list lput (list ((99 * (?1 - minFlow) / (maxFlow - minFlow)) + 1) ?2) trafficFlow-wpr-list</font><font color="#000000">
   </font><font color="#5a5a5a">;     if ?1 &gt; 1 and ?2 &gt; 0</font><font color="#000000">
    </font><font color="#5a5a5a">;    [</font><font color="#000000">
       </font><font color="#5a5a5a">;   set trafficFlow-betweeness-list lput (list ?1 ?2) trafficFlow-betweeness-list</font><font color="#000000">
   </font><font color="#5a5a5a">;     ]</font><font color="#000000">
   </font><font color="#5a5a5a">;   ])</font><font color="#000000">
   </font><font color="#5a5a5a">; set trafficFlow-betweeness-list sort-by [(item 0 ?1)&lt;(item 0 ?2)] trafficFlow-betweeness-list</font><font color="#000000">
  </font><font color="#5a5a5a">;  foreach trafficFlow-betweeness-list</font><font color="#000000">
  </font><font color="#5a5a5a">;  [</font><font color="#000000">
  </font><font color="#5a5a5a">;    plotxy (log(item 0 ?)10) (log(item 1 ?)10)</font><font color="#000000">
      </font><font color="#5a5a5a">;plotxy ((item 0 ?)^ 0.25) ((item 1 ?)^ 0.25)</font><font color="#000000">
  </font><font color="#5a5a5a">;  ]</font><font color="#000000">
   </font><font color="#5a5a5a">; let trafficFlow-list-quarter map [? ^ 0.25] trafficFlow-list</font><font color="#000000">
    </font><font color="#5a5a5a">;let betweeness-list-quarter map [? ^ 0.25] betweeness-list</font><font color="#000000">
 </font><font color="#5a5a5a">;   let betweeness-list-quarter map [? ^ 0.25] blist</font><font color="#000000">
    </font><font color="#5a5a5a">;fixed precision for number</font><font color="#000000">
 </font><font color="#5a5a5a">;   let rSquare-str (word calculateRS betweeness-list-quarter trafficFlow-list-quarter)</font><font color="#000000">
 </font><font color="#5a5a5a">;   while [(length rSquare-str)&lt; 7]</font><font color="#000000">
 </font><font color="#5a5a5a">;   [</font><font color="#000000">
      </font><font color="#0000aa">set</font><font color="#000000"> rSquare-str (</font><font color="#660096">word</font><font color="#000000"> rSquare-str </font><font color="#963700">0</font><font color="#000000">)
  </font><font color="#5a5a5a">;  ]</font><font color="#000000">
  </font><font color="#5a5a5a">;  set rSquare-str (substring rSquare-str 0 7)</font><font color="#000000">
  </font><font color="#5a5a5a">;  set R-Square rSquare-str</font><font color="#000000">
    </font><font color="#5a5a5a">;set R-square precision (calculateRS wpr-list-quarter trafficFlow-list-quarter) 5</font><font color="#000000">
 ]
</font><font color="#007f69">end</font><font color="#000000">
</font><font color="#5a5a5a">;Report the distance of a point to the original point on the line</font><font color="#000000">
</font><font color="#007f69">to-report</font><font color="#000000"> distanceToFrom [streetid pt]
  </font><font color="#0000aa">let</font><font color="#000000"> streetFeature </font><font color="#660096">item</font><font color="#000000"> streetid streetdata
  </font><font color="#0000aa">let</font><font color="#000000"> x1 </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">2</font><font color="#000000"> streetFeature
  </font><font color="#0000aa">let</font><font color="#000000"> y1 </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">3</font><font color="#000000"> streetFeature
  </font><font color="#0000aa">let</font><font color="#000000"> x2 </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">0</font><font color="#000000"> pt
  </font><font color="#0000aa">let</font><font color="#000000"> y2 </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000"> pt
  </font><font color="#0000aa">let</font><font color="#000000"> s </font><font color="#660096">sqrt</font><font color="#000000">((x2 </font><font color="#660096">-</font><font color="#000000"> x1)</font><font color="#660096">*</font><font color="#000000">(x2 </font><font color="#660096">-</font><font color="#000000"> x1)</font><font color="#660096">+</font><font color="#000000">(y2 </font><font color="#660096">-</font><font color="#000000"> y1)</font><font color="#660096">*</font><font color="#000000">(y2 </font><font color="#660096">-</font><font color="#000000"> y1))
  </font><font color="#0000aa">report</font><font color="#000000"> s
</font><font color="#007f69">end</font><font color="#000000">
</font><font color="#5a5a5a">;Report the length of a line</font><font color="#000000">
</font><font color="#007f69">to-report</font><font color="#000000"> distanceToOrig [street id]
  </font><font color="#0000aa">ifelse</font><font color="#000000"> id </font><font color="#660096">!=</font><font color="#000000"> </font><font color="#963700">0</font><font color="#000000">
  [
    </font><font color="#0000aa">let</font><font color="#000000"> x1 </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">2</font><font color="#000000"> street
    </font><font color="#0000aa">let</font><font color="#000000"> y1 </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">3</font><font color="#000000"> street
    </font><font color="#0000aa">let</font><font color="#000000"> x2 </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">4</font><font color="#000000"> street
    </font><font color="#0000aa">let</font><font color="#000000"> y2 </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">5</font><font color="#000000"> street
    </font><font color="#0000aa">let</font><font color="#000000"> s </font><font color="#660096">sqrt</font><font color="#000000">((x2 </font><font color="#660096">-</font><font color="#000000"> x1)</font><font color="#660096">*</font><font color="#000000">(x2 </font><font color="#660096">-</font><font color="#000000"> x1)</font><font color="#660096">+</font><font color="#000000">(y2 </font><font color="#660096">-</font><font color="#000000"> y1)</font><font color="#660096">*</font><font color="#000000">(y2 </font><font color="#660096">-</font><font color="#000000"> y1))
    </font><font color="#0000aa">report</font><font color="#000000"> s
  ]
  [
    </font><font color="#0000aa">report</font><font color="#000000"> </font><font color="#963700">0</font><font color="#000000">
  ]
</font><font color="#007f69">end</font><font color="#000000">
</font><font color="#5a5a5a">;Movement of purposive agents</font><font color="#000000">
</font><font color="#007f69">to</font><font color="#000000"> move-agents-purposive [who-num]
  </font><font color="#0000aa">ask</font><font color="#000000"> goalman who-num
  [
    </font><font color="#5a5a5a">;Decide direction to go</font><font color="#000000">
    </font><font color="#0000aa">if</font><font color="#000000"> direction </font><font color="#660096">=</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000"> </font><font color="#5a5a5a">;;from direction</font><font color="#000000">
    [
      </font><font color="#0000aa">let</font><font color="#000000"> street </font><font color="#660096">item</font><font color="#000000"> cur-street streetdata
      </font><font color="#5a5a5a">;Get the nearest agent in front of the current agent</font><font color="#000000">
      </font><font color="#0000aa">let</font><font color="#000000"> travelLen speed
      </font><font color="#0000aa">let</font><font color="#000000"> pLenth cur-length </font><font color="#660096">-</font><font color="#000000"> travelLen
      </font><font color="#0000aa">ifelse</font><font color="#000000"> pLenth </font><font color="#660096">&gt;=</font><font color="#000000"> junc-length
      [
      </font><font color="#5a5a5a">;Walk along one path segment of the shortest path</font><font color="#000000">
        </font><font color="#0000aa">let</font><font color="#000000"> node1 </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">0</font><font color="#000000"> street
        </font><font color="#0000aa">let</font><font color="#000000"> node2 </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000"> street
        </font><font color="#0000aa">let</font><font color="#000000"> angle [</font><font color="#660096">link-heading</font><font color="#000000">] </font><font color="#660096">of</font><font color="#000000"> </font><font color="#660096">link</font><font color="#000000"> node1 node2
        </font><font color="#0000aa">ifelse</font><font color="#000000"> angle </font><font color="#660096">&lt;</font><font color="#000000"> </font><font color="#963700">180</font><font color="#000000">
        [
          </font><font color="#0000aa">set</font><font color="#000000"> angle angle </font><font color="#660096">+</font><font color="#000000"> </font><font color="#963700">180</font><font color="#000000">
        ]
        [
          </font><font color="#0000aa">set</font><font color="#000000"> angle angle </font><font color="#660096">-</font><font color="#000000"> </font><font color="#963700">180</font><font color="#000000">
        ]
        </font><font color="#0000aa">set</font><font color="#000000"> last-location </font><font color="#660096">list</font><font color="#000000"> </font><font color="#660096">xcor</font><font color="#000000"> </font><font color="#660096">ycor</font><font color="#000000">
        </font><font color="#0000aa">set</font><font color="#000000"> </font><font color="#660096">heading</font><font color="#000000"> angle
        </font><font color="#0000aa">fd</font><font color="#000000"> travelLen
        </font><font color="#0000aa">set</font><font color="#000000"> cur-length pLenth
        </font><font color="#5a5a5a">;Count aggregate flow, footprint</font><font color="#000000">
        </font><font color="#0000aa">let</font><font color="#000000"> tracked </font><font color="#660096">item</font><font color="#000000"> cur-street tracked-goal-list
        </font><font color="#0000aa">set</font><font color="#000000"> tracked tracked </font><font color="#660096">+</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000">
        </font><font color="#0000aa">set</font><font color="#000000"> tracked-goal-list </font><font color="#660096">replace-item</font><font color="#000000"> cur-street tracked-goal-list tracked
      ]
      [
      </font><font color="#5a5a5a">;Finish current path segment of the shortest path</font><font color="#000000">
        </font><font color="#0000aa">ifelse</font><font color="#000000"> next-street </font><font color="#660096">!=</font><font color="#000000"> </font><font color="#963700">-1</font><font color="#000000">
        [
          </font><font color="#5a5a5a">;Choose next path segment as the current path segment</font><font color="#000000">
          </font><font color="#0000aa">set</font><font color="#000000"> last-location </font><font color="#660096">list</font><font color="#000000"> </font><font color="#660096">xcor</font><font color="#000000"> </font><font color="#660096">ycor</font><font color="#000000">
          </font><font color="#0000aa">setxy</font><font color="#000000"> </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">0</font><font color="#000000"> junc-point </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000"> junc-point
          </font><font color="#0000aa">let</font><font color="#000000"> a-street </font><font color="#660096">item</font><font color="#000000"> next-street streetdata
          </font><font color="#0000aa">let</font><font color="#000000"> x8 </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">2</font><font color="#000000"> a-street
          </font><font color="#0000aa">let</font><font color="#000000"> y8 </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">3</font><font color="#000000"> a-street
          </font><font color="#0000aa">set</font><font color="#000000"> cur-length </font><font color="#660096">sqrt</font><font color="#000000">((</font><font color="#660096">xcor</font><font color="#000000"> </font><font color="#660096">-</font><font color="#000000"> x8) </font><font color="#660096">*</font><font color="#000000"> (</font><font color="#660096">xcor</font><font color="#000000"> </font><font color="#660096">-</font><font color="#000000"> x8) </font><font color="#660096">+</font><font color="#000000"> (</font><font color="#660096">ycor</font><font color="#000000"> </font><font color="#660096">-</font><font color="#000000"> y8) </font><font color="#660096">*</font><font color="#000000"> (</font><font color="#660096">ycor</font><font color="#000000"> </font><font color="#660096">-</font><font color="#000000"> y8))
          </font><font color="#0000aa">set</font><font color="#000000"> last-street cur-street
          </font><font color="#0000aa">set</font><font color="#000000"> cur-street next-street
          </font><font color="#0000aa">set</font><font color="#000000"> next-street </font><font color="#963700">-1</font><font color="#000000">
          </font><font color="#0000aa">set</font><font color="#000000"> junc-length </font><font color="#963700">0</font><font color="#000000">
          </font><font color="#0000aa">set</font><font color="#000000"> junc-point (</font><font color="#660096">list</font><font color="#000000">)
          </font><font color="#0000aa">set</font><font color="#000000"> direction </font><font color="#963700">0</font><font color="#000000">  
          </font><font color="#5a5a5a">;;Count aggregate flow, footprint</font><font color="#000000">
          </font><font color="#0000aa">let</font><font color="#000000"> tracked </font><font color="#660096">item</font><font color="#000000"> cur-street tracked-goal-list
          </font><font color="#0000aa">set</font><font color="#000000"> tracked tracked </font><font color="#660096">+</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000">
          </font><font color="#0000aa">set</font><font color="#000000"> tracked-goal-list </font><font color="#660096">replace-item</font><font color="#000000"> cur-street tracked-goal-list tracked
          </font><font color="#0000aa">let</font><font color="#000000"> visited </font><font color="#660096">item</font><font color="#000000"> cur-street visited-goal-list
          </font><font color="#0000aa">set</font><font color="#000000"> visited visited </font><font color="#660096">+</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000">
          </font><font color="#0000aa">set</font><font color="#000000"> visited-goal-list </font><font color="#660096">replace-item</font><font color="#000000"> cur-street visited-goal-list visited
        ]
        [
          </font><font color="#5a5a5a">;Finish the whole path</font><font color="#000000">
          </font><font color="#0000aa">set</font><font color="#000000"> last-location </font><font color="#660096">list</font><font color="#000000"> </font><font color="#660096">xcor</font><font color="#000000"> </font><font color="#660096">ycor</font><font color="#000000">
          </font><font color="#0000aa">set</font><font color="#000000"> last-street cur-street
          </font><font color="#0000aa">setxy</font><font color="#000000"> </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">0</font><font color="#000000"> junc-point </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000"> junc-point
          </font><font color="#0000aa">set</font><font color="#000000"> cur-length junc-length    
          </font><font color="#0000aa">set</font><font color="#000000"> junc-point (</font><font color="#660096">list</font><font color="#000000">)
          </font><font color="#0000aa">set</font><font color="#000000"> next-street </font><font color="#963700">-1</font><font color="#000000">
          </font><font color="#0000aa">set</font><font color="#000000"> junc-length </font><font color="#963700">0</font><font color="#000000">
          </font><font color="#5a5a5a">;Count aggregate flow, footprint</font><font color="#000000">
          </font><font color="#0000aa">let</font><font color="#000000"> tracked </font><font color="#660096">item</font><font color="#000000"> cur-street tracked-goal-list
          </font><font color="#0000aa">set</font><font color="#000000"> tracked tracked </font><font color="#660096">+</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000">
          </font><font color="#0000aa">set</font><font color="#000000"> tracked-goal-list </font><font color="#660096">replace-item</font><font color="#000000"> cur-street tracked-goal-list tracked 
                 
          </font><font color="#0000aa">set</font><font color="#000000"> direction </font><font color="#963700">0</font><font color="#000000">
          </font><font color="#0000aa">set</font><font color="#000000"> cur-street </font><font color="#963700">-1</font><font color="#000000">
        ]
      ]
    ]
    </font><font color="#0000aa">if</font><font color="#000000"> direction </font><font color="#660096">=</font><font color="#000000"> </font><font color="#963700">2</font><font color="#000000">   </font><font color="#5a5a5a">;to direction</font><font color="#000000">
    [
      </font><font color="#0000aa">let</font><font color="#000000"> street </font><font color="#660096">item</font><font color="#000000"> cur-street streetdata
      </font><font color="#0000aa">let</font><font color="#000000"> travelLen speed
      </font><font color="#0000aa">let</font><font color="#000000"> pLenth cur-length </font><font color="#660096">+</font><font color="#000000"> travelLen
      </font><font color="#0000aa">ifelse</font><font color="#000000"> pLenth </font><font color="#660096">&lt;=</font><font color="#000000"> junc-length
      [
      </font><font color="#5a5a5a">;Walk along one path segment of the shortest path</font><font color="#000000">
        </font><font color="#0000aa">let</font><font color="#000000"> node1 </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">0</font><font color="#000000"> street
        </font><font color="#0000aa">let</font><font color="#000000"> node2 </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000"> street
        </font><font color="#0000aa">let</font><font color="#000000"> angle [</font><font color="#660096">link-heading</font><font color="#000000">] </font><font color="#660096">of</font><font color="#000000"> </font><font color="#660096">link</font><font color="#000000"> node1 node2
        </font><font color="#0000aa">set</font><font color="#000000"> last-location </font><font color="#660096">list</font><font color="#000000"> </font><font color="#660096">xcor</font><font color="#000000"> </font><font color="#660096">ycor</font><font color="#000000">
        </font><font color="#0000aa">set</font><font color="#000000"> </font><font color="#660096">heading</font><font color="#000000"> angle
        </font><font color="#0000aa">fd</font><font color="#000000"> travelLen
        </font><font color="#0000aa">set</font><font color="#000000"> cur-length pLenth
        </font><font color="#5a5a5a">;Count aggregate flow, footprint</font><font color="#000000">
        </font><font color="#0000aa">let</font><font color="#000000"> tracked </font><font color="#660096">item</font><font color="#000000"> cur-street tracked-goal-list
        </font><font color="#0000aa">set</font><font color="#000000"> tracked tracked </font><font color="#660096">+</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000">
        </font><font color="#0000aa">set</font><font color="#000000"> tracked-goal-list </font><font color="#660096">replace-item</font><font color="#000000"> cur-street tracked-goal-list tracked
      ]
      [
      </font><font color="#5a5a5a">;Finish current path segment of the shortest path</font><font color="#000000">
        </font><font color="#0000aa">ifelse</font><font color="#000000"> next-street </font><font color="#660096">!=</font><font color="#000000"> </font><font color="#963700">-1</font><font color="#000000">
        [
          </font><font color="#5a5a5a">;Choose next path segment as the current path segment</font><font color="#000000">
          </font><font color="#0000aa">let</font><font color="#000000"> b-street </font><font color="#660096">item</font><font color="#000000"> next-street streetdata
          </font><font color="#0000aa">let</font><font color="#000000"> x9 </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">2</font><font color="#000000"> b-street
          </font><font color="#0000aa">let</font><font color="#000000"> y9 </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">3</font><font color="#000000"> b-street
          </font><font color="#0000aa">set</font><font color="#000000"> last-location </font><font color="#660096">list</font><font color="#000000"> </font><font color="#660096">xcor</font><font color="#000000"> </font><font color="#660096">ycor</font><font color="#000000">
          </font><font color="#0000aa">setxy</font><font color="#000000"> </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">0</font><font color="#000000"> junc-point </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000"> junc-point
          </font><font color="#0000aa">set</font><font color="#000000"> cur-length </font><font color="#660096">sqrt</font><font color="#000000">((</font><font color="#660096">xcor</font><font color="#000000"> </font><font color="#660096">-</font><font color="#000000"> x9) </font><font color="#660096">*</font><font color="#000000"> (</font><font color="#660096">xcor</font><font color="#000000"> </font><font color="#660096">-</font><font color="#000000"> x9) </font><font color="#660096">+</font><font color="#000000"> (</font><font color="#660096">ycor</font><font color="#000000"> </font><font color="#660096">-</font><font color="#000000"> y9) </font><font color="#660096">*</font><font color="#000000"> (</font><font color="#660096">ycor</font><font color="#000000"> </font><font color="#660096">-</font><font color="#000000"> y9))
          </font><font color="#0000aa">set</font><font color="#000000"> last-street cur-street
          </font><font color="#0000aa">set</font><font color="#000000"> cur-street next-street
          </font><font color="#0000aa">set</font><font color="#000000"> next-street </font><font color="#963700">-1</font><font color="#000000">
          </font><font color="#0000aa">set</font><font color="#000000"> junc-length </font><font color="#963700">0</font><font color="#000000">
          </font><font color="#0000aa">set</font><font color="#000000"> junc-point (</font><font color="#660096">list</font><font color="#000000">)
          </font><font color="#0000aa">set</font><font color="#000000"> direction </font><font color="#963700">0</font><font color="#000000"> 
          </font><font color="#5a5a5a">;Count aggregate flow, footprint and topological counts</font><font color="#000000">
          </font><font color="#0000aa">let</font><font color="#000000"> tracked </font><font color="#660096">item</font><font color="#000000"> cur-street tracked-goal-list
          </font><font color="#0000aa">set</font><font color="#000000"> tracked tracked </font><font color="#660096">+</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000">
          </font><font color="#0000aa">set</font><font color="#000000"> tracked-goal-list </font><font color="#660096">replace-item</font><font color="#000000"> cur-street tracked-goal-list tracked
          </font><font color="#0000aa">let</font><font color="#000000"> visited </font><font color="#660096">item</font><font color="#000000"> cur-street visited-goal-list
          </font><font color="#0000aa">set</font><font color="#000000"> visited visited </font><font color="#660096">+</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000">
          </font><font color="#0000aa">set</font><font color="#000000"> visited-goal-list </font><font color="#660096">replace-item</font><font color="#000000"> cur-street visited-goal-list visited
        ]
        [
          </font><font color="#5a5a5a">;Finish the whole path</font><font color="#000000">
          </font><font color="#0000aa">set</font><font color="#000000"> last-location </font><font color="#660096">list</font><font color="#000000"> </font><font color="#660096">xcor</font><font color="#000000"> </font><font color="#660096">ycor</font><font color="#000000">
          </font><font color="#0000aa">set</font><font color="#000000"> last-street cur-street
          </font><font color="#0000aa">setxy</font><font color="#000000"> </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">0</font><font color="#000000"> junc-point </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000"> junc-point
          </font><font color="#0000aa">set</font><font color="#000000"> cur-length junc-length     
          </font><font color="#0000aa">set</font><font color="#000000"> junc-point (</font><font color="#660096">list</font><font color="#000000">)
          </font><font color="#0000aa">set</font><font color="#000000"> next-street </font><font color="#963700">-1</font><font color="#000000">
          </font><font color="#0000aa">set</font><font color="#000000"> junc-length </font><font color="#963700">0</font><font color="#000000">
          </font><font color="#5a5a5a">;Count aggregate flow, footprint</font><font color="#000000">
          </font><font color="#0000aa">let</font><font color="#000000"> tracked </font><font color="#660096">item</font><font color="#000000"> cur-street tracked-goal-list
          </font><font color="#0000aa">set</font><font color="#000000"> tracked tracked </font><font color="#660096">+</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000">
          </font><font color="#0000aa">set</font><font color="#000000"> tracked-goal-list </font><font color="#660096">replace-item</font><font color="#000000"> cur-street tracked-goal-list tracked 
          
          </font><font color="#0000aa">set</font><font color="#000000"> direction </font><font color="#963700">0</font><font color="#000000">
          </font><font color="#0000aa">set</font><font color="#000000"> cur-street </font><font color="#963700">-1</font><font color="#000000">
        ]
      ]
    ]
    </font><font color="#0000aa">if</font><font color="#000000"> direction </font><font color="#660096">=</font><font color="#000000"> </font><font color="#963700">0</font><font color="#000000"> </font><font color="#5a5a5a">;;no direction</font><font color="#000000">
    [
      </font><font color="#5a5a5a">;purposive agent reaches the destination</font><font color="#000000">
      </font><font color="#0000aa">ifelse</font><font color="#000000"> (cur-street </font><font color="#660096">=</font><font color="#000000"> </font><font color="#963700">-1</font><font color="#000000">)</font><font color="#660096">and</font><font color="#000000">(next-street </font><font color="#660096">=</font><font color="#000000"> </font><font color="#963700">-1</font><font color="#000000">)
      [
        </font><font color="#5a5a5a">;Keep the old destination point as the new start point, and only choose a new destination based on purposive walker behavior </font><font color="#000000">
        ResetDestination </font><font color="#660096">who</font><font color="#000000"> 
        </font><font color="#5a5a5a">;Set the red color for the destination street</font><font color="#000000">
</font><font color="#5a5a5a">;        ask link (item 0 (item cur-street streetdata)) (item 1 (item cur-street streetdata)) </font><font color="#000000">
</font><font color="#5a5a5a">;        [</font><font color="#000000">
</font><font color="#5a5a5a">;          set color white</font><font color="#000000">
</font><font color="#5a5a5a">;        ] </font><font color="#000000">
</font><font color="#5a5a5a">;        ask destinations</font><font color="#000000">
</font><font color="#5a5a5a">;        [</font><font color="#000000">
</font><font color="#5a5a5a">;          die</font><font color="#000000">
</font><font color="#5a5a5a">;        ] </font><font color="#000000">
</font><font color="#5a5a5a">;        ask link (item 0 (item dest-street streetdata)) (item 1 (item dest-street streetdata)) </font><font color="#000000">
</font><font color="#5a5a5a">;        [</font><font color="#000000">
</font><font color="#5a5a5a">;          set color red</font><font color="#000000">
</font><font color="#5a5a5a">;        ]  </font><font color="#000000">
</font><font color="#5a5a5a">;        hatch-destinations 1</font><font color="#000000">
</font><font color="#5a5a5a">;        [</font><font color="#000000">
</font><font color="#5a5a5a">;          setxy ([dest-x]of goalman who-num) ([dest-y]of goalman who-num)</font><font color="#000000">
</font><font color="#5a5a5a">;          set size 2.5</font><font color="#000000">
</font><font color="#5a5a5a">;          set shape &quot;flag&quot;</font><font color="#000000">
</font><font color="#5a5a5a">;          set color blue</font><font color="#000000">
</font><font color="#5a5a5a">;        ]                    </font><font color="#000000">
      ]
      </font><font color="#5a5a5a">;purposive agent does not reach the destination, set the next path segment</font><font color="#000000">
      [
        </font><font color="#0000aa">let</font><font color="#000000"> lastStreetId </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">0</font><font color="#000000"> (</font><font color="#660096">item</font><font color="#000000"> ((</font><font color="#660096">length</font><font color="#000000"> path-goal)</font><font color="#660096">-</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000">) path-goal)
        </font><font color="#5a5a5a">;Current path segment is the last path segment of the shortest path, Set the next path segment as -1</font><font color="#000000">
        </font><font color="#0000aa">ifelse</font><font color="#000000"> cur-street </font><font color="#660096">=</font><font color="#000000"> lastStreetId
        [
          </font><font color="#0000aa">set</font><font color="#000000"> next-street </font><font color="#963700">-1</font><font color="#000000">
          </font><font color="#0000aa">let</font><font color="#000000"> x2 </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">3</font><font color="#000000"> (</font><font color="#660096">item</font><font color="#000000"> ((</font><font color="#660096">length</font><font color="#000000"> path-goal)</font><font color="#660096">-</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000">) path-goal)
          </font><font color="#0000aa">let</font><font color="#000000"> y2 </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">4</font><font color="#000000"> (</font><font color="#660096">item</font><font color="#000000"> ((</font><font color="#660096">length</font><font color="#000000"> path-goal)</font><font color="#660096">-</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000">) path-goal) 
          </font><font color="#0000aa">set</font><font color="#000000"> junc-point </font><font color="#660096">list</font><font color="#000000"> x2 y2
          </font><font color="#0000aa">set</font><font color="#000000"> junc-length distanceToFrom cur-street junc-point
          </font><font color="#0000aa">if</font><font color="#000000"> cur-length </font><font color="#660096">&gt;</font><font color="#000000"> junc-length
          [
            </font><font color="#0000aa">set</font><font color="#000000"> direction </font><font color="#963700">1</font><font color="#000000">                 </font><font color="#5a5a5a">; ;0-no;1-from;2-to</font><font color="#000000">
            move-agents-purposive </font><font color="#660096">who</font><font color="#000000">
          ]
          </font><font color="#0000aa">if</font><font color="#000000"> cur-length </font><font color="#660096">&lt;</font><font color="#000000"> junc-length
          [
            </font><font color="#0000aa">set</font><font color="#000000"> direction </font><font color="#963700">2</font><font color="#000000">
            move-agents-purposive </font><font color="#660096">who</font><font color="#000000">
          ]
          </font><font color="#0000aa">if</font><font color="#000000"> cur-length </font><font color="#660096">=</font><font color="#000000"> junc-length
          [
            </font><font color="#0000aa">set</font><font color="#000000"> direction </font><font color="#963700">0</font><font color="#000000">
            </font><font color="#0000aa">set</font><font color="#000000"> last-street cur-street
            </font><font color="#0000aa">set</font><font color="#000000"> cur-street </font><font color="#963700">-1</font><font color="#000000">
            </font><font color="#0000aa">set</font><font color="#000000"> next-street </font><font color="#963700">-1</font><font color="#000000">
            </font><font color="#0000aa">set</font><font color="#000000"> junc-point (</font><font color="#660096">list</font><font color="#000000">)
            </font><font color="#0000aa">set</font><font color="#000000"> junc-length </font><font color="#963700">0</font><font color="#000000">
            move-agents-purposive </font><font color="#660096">who</font><font color="#000000">
          ]
        ]
        </font><font color="#5a5a5a">;There exists a next path segment in the shortest path</font><font color="#000000">
        [
          </font><font color="#5a5a5a">;Find the index of the currentRoad ID in the pathIDs and to set next street, street junction, junction length</font><font color="#000000">
          </font><font color="#0000aa">let</font><font color="#000000"> pathsegments </font><font color="#660096">sublist</font><font color="#000000"> path-goal </font><font color="#963700">1</font><font color="#000000"> (</font><font color="#660096">length</font><font color="#000000"> path-goal)
          </font><font color="#0000aa">let</font><font color="#000000"> curStreetIndexList (</font><font color="#660096">list</font><font color="#000000">)
          </font><font color="#0000aa">let</font><font color="#000000"> index </font><font color="#963700">0</font><font color="#000000">
          </font><font color="#0000aa">foreach</font><font color="#000000"> pathsegments
          [
            </font><font color="#0000aa">let</font><font color="#000000"> pathID </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">0</font><font color="#000000"> ?
            </font><font color="#0000aa">if</font><font color="#000000"> pathID </font><font color="#660096">=</font><font color="#000000"> cur-street
            [
              </font><font color="#0000aa">set</font><font color="#000000"> curStreetIndexList </font><font color="#660096">lput</font><font color="#000000"> index curStreetIndexList
            ]
            </font><font color="#0000aa">set</font><font color="#000000"> index index </font><font color="#660096">+</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000">
          ]
          </font><font color="#0000aa">let</font><font color="#000000"> curStreetIndex </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">0</font><font color="#000000"> curStreetIndexList
          </font><font color="#0000aa">let</font><font color="#000000"> nextPathSegment </font><font color="#660096">item</font><font color="#000000"> (curStreetIndex </font><font color="#660096">+</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000">)  pathSegments
          </font><font color="#0000aa">set</font><font color="#000000"> next-street </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">0</font><font color="#000000"> nextPathSegment
          </font><font color="#0000aa">let</font><font color="#000000"> x3 </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000"> nextPathSegment
          </font><font color="#0000aa">let</font><font color="#000000"> y3 </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">2</font><font color="#000000"> nextPathSegment
          </font><font color="#0000aa">set</font><font color="#000000"> junc-point </font><font color="#660096">list</font><font color="#000000"> x3 y3
          </font><font color="#0000aa">set</font><font color="#000000"> junc-length distanceToFrom cur-street junc-point
          </font><font color="#0000aa">set</font><font color="#000000"> cur-length distanceToFrom cur-street (</font><font color="#660096">list</font><font color="#000000"> </font><font color="#660096">xcor</font><font color="#000000"> </font><font color="#660096">ycor</font><font color="#000000">)
          
          </font><font color="#0000aa">if</font><font color="#000000"> cur-length </font><font color="#660096">&gt;</font><font color="#000000"> junc-length
          [
            </font><font color="#0000aa">set</font><font color="#000000"> direction </font><font color="#963700">1</font><font color="#000000">                 </font><font color="#5a5a5a">;;0:no;1:from;2:to</font><font color="#000000">
            move-agents-purposive </font><font color="#660096">who</font><font color="#000000">
          ]
          </font><font color="#0000aa">if</font><font color="#000000"> cur-length </font><font color="#660096">&lt;</font><font color="#000000"> junc-length
          [
            </font><font color="#0000aa">set</font><font color="#000000"> direction </font><font color="#963700">2</font><font color="#000000">
            move-agents-purposive </font><font color="#660096">who</font><font color="#000000">
          ]
          </font><font color="#0000aa">if</font><font color="#000000"> cur-length </font><font color="#660096">=</font><font color="#000000"> junc-length
          [     
            </font><font color="#0000aa">set</font><font color="#000000"> direction </font><font color="#963700">0</font><font color="#000000">
            </font><font color="#0000aa">set</font><font color="#000000"> last-street cur-street
            </font><font color="#0000aa">set</font><font color="#000000"> cur-street next-street
            </font><font color="#0000aa">set</font><font color="#000000"> next-street </font><font color="#963700">-1</font><font color="#000000">
            </font><font color="#0000aa">set</font><font color="#000000"> junc-point (</font><font color="#660096">list</font><font color="#000000">)
            </font><font color="#0000aa">set</font><font color="#000000"> junc-length </font><font color="#963700">0</font><font color="#000000">
            </font><font color="#0000aa">set</font><font color="#000000"> cur-length distanceToFrom cur-street (</font><font color="#660096">list</font><font color="#000000"> </font><font color="#660096">xcor</font><font color="#000000"> </font><font color="#660096">ycor</font><font color="#000000">)
            move-agents-purposive </font><font color="#660096">who</font><font color="#000000">
          ]
        ]
      ]      
    ]
  ]
</font><font color="#007f69">end</font><font color="#000000">
</font><font color="#5a5a5a">;Movement of random agents</font><font color="#000000">
</font><font color="#007f69">to</font><font color="#000000"> move-agents-random [who-num]
  </font><font color="#0000aa">ask</font><font color="#000000"> person who-num
  [
    </font><font color="#0000aa">let</font><font color="#000000"> travelLen speed   
    </font><font color="#5a5a5a">;Decide direction to go</font><font color="#000000">
    </font><font color="#0000aa">if</font><font color="#000000"> direction </font><font color="#660096">=</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000"> </font><font color="#5a5a5a">;;from direction</font><font color="#000000">
    [
      </font><font color="#0000aa">let</font><font color="#000000"> street </font><font color="#660096">item</font><font color="#000000"> cur-street streetdata
      </font><font color="#0000aa">let</font><font color="#000000"> pLenth cur-length </font><font color="#660096">-</font><font color="#000000"> travelLen
      </font><font color="#0000aa">ifelse</font><font color="#000000"> pLenth </font><font color="#660096">&gt;=</font><font color="#000000"> junc-length
      [
        </font><font color="#5a5a5a">;Walk along the current street towards the next street</font><font color="#000000">
        </font><font color="#0000aa">let</font><font color="#000000"> node1 </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">0</font><font color="#000000"> street
        </font><font color="#0000aa">let</font><font color="#000000"> node2 </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000"> street
        </font><font color="#0000aa">let</font><font color="#000000"> angle [</font><font color="#660096">link-heading</font><font color="#000000">] </font><font color="#660096">of</font><font color="#000000"> </font><font color="#660096">link</font><font color="#000000"> node1 node2
        </font><font color="#0000aa">ifelse</font><font color="#000000"> angle </font><font color="#660096">&lt;</font><font color="#000000"> </font><font color="#963700">180</font><font color="#000000">
        [
          </font><font color="#0000aa">set</font><font color="#000000"> angle angle </font><font color="#660096">+</font><font color="#000000"> </font><font color="#963700">180</font><font color="#000000">
        ]
        [
          </font><font color="#0000aa">set</font><font color="#000000"> angle angle </font><font color="#660096">-</font><font color="#000000"> </font><font color="#963700">180</font><font color="#000000">
        ]
        </font><font color="#0000aa">set</font><font color="#000000"> last-location </font><font color="#660096">list</font><font color="#000000"> </font><font color="#660096">xcor</font><font color="#000000"> </font><font color="#660096">ycor</font><font color="#000000">
        </font><font color="#0000aa">set</font><font color="#000000"> </font><font color="#660096">heading</font><font color="#000000"> angle
        </font><font color="#0000aa">fd</font><font color="#000000"> travelLen
        </font><font color="#0000aa">set</font><font color="#000000"> cur-length pLenth
        </font><font color="#5a5a5a">;Count aggregate flow, footprint</font><font color="#000000">
        </font><font color="#0000aa">let</font><font color="#000000"> tracked </font><font color="#660096">item</font><font color="#000000"> cur-street tracked-list
        </font><font color="#0000aa">set</font><font color="#000000"> tracked tracked </font><font color="#660096">+</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000">
        </font><font color="#0000aa">set</font><font color="#000000"> tracked-list </font><font color="#660096">replace-item</font><font color="#000000"> cur-street tracked-list tracked
      ]
      [
        </font><font color="#5a5a5a">;Finish the journey of the current street, and set the next street to the current street</font><font color="#000000">
        </font><font color="#0000aa">set</font><font color="#000000"> last-location </font><font color="#660096">list</font><font color="#000000"> </font><font color="#660096">xcor</font><font color="#000000"> </font><font color="#660096">ycor</font><font color="#000000">
        </font><font color="#0000aa">setxy</font><font color="#000000"> </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">0</font><font color="#000000"> junc-point </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000"> junc-point
        </font><font color="#0000aa">let</font><font color="#000000"> a-street </font><font color="#660096">item</font><font color="#000000"> next-street streetdata
        </font><font color="#0000aa">let</font><font color="#000000"> x8 </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">2</font><font color="#000000"> a-street
        </font><font color="#0000aa">let</font><font color="#000000"> y8 </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">3</font><font color="#000000"> a-street
        </font><font color="#0000aa">set</font><font color="#000000"> cur-length </font><font color="#660096">sqrt</font><font color="#000000">((</font><font color="#660096">xcor</font><font color="#000000"> </font><font color="#660096">-</font><font color="#000000"> x8) </font><font color="#660096">*</font><font color="#000000"> (</font><font color="#660096">xcor</font><font color="#000000"> </font><font color="#660096">-</font><font color="#000000"> x8) </font><font color="#660096">+</font><font color="#000000"> (</font><font color="#660096">ycor</font><font color="#000000"> </font><font color="#660096">-</font><font color="#000000"> y8) </font><font color="#660096">*</font><font color="#000000"> (</font><font color="#660096">ycor</font><font color="#000000"> </font><font color="#660096">-</font><font color="#000000"> y8))
        </font><font color="#0000aa">set</font><font color="#000000"> last-street cur-street
        </font><font color="#0000aa">set</font><font color="#000000"> cur-street next-street
        </font><font color="#0000aa">set</font><font color="#000000"> next-street </font><font color="#963700">-1</font><font color="#000000">
        </font><font color="#0000aa">set</font><font color="#000000"> junc-length </font><font color="#963700">0</font><font color="#000000">
        </font><font color="#0000aa">set</font><font color="#000000"> junc-point (</font><font color="#660096">list</font><font color="#000000">)
        </font><font color="#0000aa">set</font><font color="#000000"> direction </font><font color="#963700">0</font><font color="#000000"> 
        </font><font color="#5a5a5a">;Count aggregate flow, footprint and topological counts</font><font color="#000000">
        </font><font color="#0000aa">let</font><font color="#000000"> tracked </font><font color="#660096">item</font><font color="#000000"> cur-street tracked-list
        </font><font color="#0000aa">set</font><font color="#000000"> tracked tracked </font><font color="#660096">+</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000">
        </font><font color="#0000aa">set</font><font color="#000000"> tracked-list </font><font color="#660096">replace-item</font><font color="#000000"> cur-street tracked-list tracked
        </font><font color="#0000aa">let</font><font color="#000000"> visited </font><font color="#660096">item</font><font color="#000000"> cur-street visited-list
        </font><font color="#0000aa">set</font><font color="#000000"> visited visited </font><font color="#660096">+</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000">
        </font><font color="#0000aa">set</font><font color="#000000"> visited-list </font><font color="#660096">replace-item</font><font color="#000000"> cur-street visited-list visited        
      ]
    ]
    </font><font color="#0000aa">if</font><font color="#000000"> direction </font><font color="#660096">=</font><font color="#000000"> </font><font color="#963700">2</font><font color="#000000"> </font><font color="#5a5a5a">;;to direction</font><font color="#000000">
    [
      </font><font color="#0000aa">let</font><font color="#000000"> street </font><font color="#660096">item</font><font color="#000000"> cur-street streetdata
      </font><font color="#0000aa">let</font><font color="#000000"> pLenth cur-length </font><font color="#660096">+</font><font color="#000000"> travelLen
      </font><font color="#0000aa">ifelse</font><font color="#000000"> pLenth </font><font color="#660096">&lt;=</font><font color="#000000"> junc-length
      [
        </font><font color="#5a5a5a">;Walk along the current street towards the next street</font><font color="#000000">
        </font><font color="#0000aa">let</font><font color="#000000"> node1 </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">0</font><font color="#000000"> street
        </font><font color="#0000aa">let</font><font color="#000000"> node2 </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000"> street
        </font><font color="#0000aa">let</font><font color="#000000"> angle [</font><font color="#660096">link-heading</font><font color="#000000">] </font><font color="#660096">of</font><font color="#000000"> </font><font color="#660096">link</font><font color="#000000"> node1 node2
        </font><font color="#0000aa">set</font><font color="#000000"> last-location </font><font color="#660096">list</font><font color="#000000"> </font><font color="#660096">xcor</font><font color="#000000"> </font><font color="#660096">ycor</font><font color="#000000">
        </font><font color="#0000aa">set</font><font color="#000000"> </font><font color="#660096">heading</font><font color="#000000"> angle
        </font><font color="#0000aa">fd</font><font color="#000000"> travelLen
        </font><font color="#0000aa">set</font><font color="#000000"> cur-length pLenth
        </font><font color="#5a5a5a">;Count aggregate flow, footprint</font><font color="#000000">
        </font><font color="#0000aa">let</font><font color="#000000"> tracked </font><font color="#660096">item</font><font color="#000000"> cur-street tracked-list
        </font><font color="#0000aa">set</font><font color="#000000"> tracked tracked </font><font color="#660096">+</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000">
        </font><font color="#0000aa">set</font><font color="#000000"> tracked-list </font><font color="#660096">replace-item</font><font color="#000000"> cur-street tracked-list tracked
      ]
      [
        </font><font color="#5a5a5a">;Finish the journey of the current street, and set the next street to the current street</font><font color="#000000">
        </font><font color="#0000aa">let</font><font color="#000000"> b-street </font><font color="#660096">item</font><font color="#000000"> next-street streetdata
        </font><font color="#0000aa">let</font><font color="#000000"> x9 </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">2</font><font color="#000000"> b-street
        </font><font color="#0000aa">let</font><font color="#000000"> y9 </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">3</font><font color="#000000"> b-street
        </font><font color="#0000aa">set</font><font color="#000000"> last-location </font><font color="#660096">list</font><font color="#000000"> </font><font color="#660096">xcor</font><font color="#000000"> </font><font color="#660096">ycor</font><font color="#000000">
        </font><font color="#0000aa">setxy</font><font color="#000000"> </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">0</font><font color="#000000"> junc-point </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000"> junc-point
        </font><font color="#0000aa">set</font><font color="#000000"> cur-length </font><font color="#660096">sqrt</font><font color="#000000">((</font><font color="#660096">xcor</font><font color="#000000"> </font><font color="#660096">-</font><font color="#000000"> x9) </font><font color="#660096">*</font><font color="#000000"> (</font><font color="#660096">xcor</font><font color="#000000"> </font><font color="#660096">-</font><font color="#000000"> x9) </font><font color="#660096">+</font><font color="#000000"> (</font><font color="#660096">ycor</font><font color="#000000"> </font><font color="#660096">-</font><font color="#000000"> y9) </font><font color="#660096">*</font><font color="#000000"> (</font><font color="#660096">ycor</font><font color="#000000"> </font><font color="#660096">-</font><font color="#000000"> y9))
        </font><font color="#0000aa">set</font><font color="#000000"> last-street cur-street
        </font><font color="#0000aa">set</font><font color="#000000"> cur-street next-street
        </font><font color="#0000aa">set</font><font color="#000000"> next-street </font><font color="#963700">-1</font><font color="#000000">
        </font><font color="#0000aa">set</font><font color="#000000"> junc-length </font><font color="#963700">0</font><font color="#000000">
        </font><font color="#0000aa">set</font><font color="#000000"> junc-point (</font><font color="#660096">list</font><font color="#000000">)
        </font><font color="#0000aa">set</font><font color="#000000"> direction </font><font color="#963700">0</font><font color="#000000">    
        </font><font color="#5a5a5a">;Count aggregate flow, footprint and topological counts</font><font color="#000000">
        </font><font color="#0000aa">let</font><font color="#000000"> tracked </font><font color="#660096">item</font><font color="#000000"> cur-street tracked-list
        </font><font color="#0000aa">set</font><font color="#000000"> tracked tracked </font><font color="#660096">+</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000">
        </font><font color="#0000aa">set</font><font color="#000000"> tracked-list </font><font color="#660096">replace-item</font><font color="#000000"> cur-street tracked-list tracked
        </font><font color="#0000aa">let</font><font color="#000000"> visited </font><font color="#660096">item</font><font color="#000000"> cur-street visited-list
        </font><font color="#0000aa">set</font><font color="#000000"> visited visited </font><font color="#660096">+</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000">
        </font><font color="#0000aa">set</font><font color="#000000"> visited-list </font><font color="#660096">replace-item</font><font color="#000000"> cur-street visited-list visited
      ]  
    ]
    </font><font color="#0000aa">if</font><font color="#000000"> direction </font><font color="#660096">=</font><font color="#000000"> </font><font color="#963700">0</font><font color="#000000">  </font><font color="#5a5a5a">;no direction</font><font color="#000000">
    [
      </font><font color="#5a5a5a">;Set the next street</font><font color="#000000">
      </font><font color="#0000aa">let</font><font color="#000000"> pDisToFrom cur-length
      </font><font color="#0000aa">let</font><font color="#000000"> intersects-street </font><font color="#660096">item</font><font color="#000000"> cur-street street-list
      </font><font color="#0000aa">let</font><font color="#000000"> next-street-list GetNextStreet intersects-street cur-street
      </font><font color="#5a5a5a">;;calculate the next-street,junc-point,junc-length and so on.</font><font color="#000000">
      </font><font color="#0000aa">set</font><font color="#000000"> next-street </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">0</font><font color="#000000"> next-street-list
      </font><font color="#5a5a5a">;get the first intersection point,the format is [first-node-id second-node-id x y]</font><font color="#000000">
      </font><font color="#0000aa">let</font><font color="#000000"> first-intersection-point </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000"> next-street-list   
      </font><font color="#5a5a5a">;let street item cur-street streetdata, and get the coordinates of the first node of the cur-street</font><font color="#000000">
      </font><font color="#0000aa">let</font><font color="#000000"> x1 [</font><font color="#660096">xcor</font><font color="#000000">] </font><font color="#660096">of</font><font color="#000000"> (node (</font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">0</font><font color="#000000"> first-intersection-point)) 
      </font><font color="#0000aa">let</font><font color="#000000"> y1 [</font><font color="#660096">ycor</font><font color="#000000">] </font><font color="#660096">of</font><font color="#000000"> (node (</font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">0</font><font color="#000000"> first-intersection-point))
      </font><font color="#0000aa">let</font><font color="#000000"> x2 </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">2</font><font color="#000000"> first-intersection-point
      </font><font color="#0000aa">let</font><font color="#000000"> y2 </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">3</font><font color="#000000"> first-intersection-point
      </font><font color="#0000aa">set</font><font color="#000000"> junc-length </font><font color="#660096">sqrt</font><font color="#000000">((x1 </font><font color="#660096">-</font><font color="#000000"> x2) </font><font color="#660096">*</font><font color="#000000"> (x1 </font><font color="#660096">-</font><font color="#000000"> x2) </font><font color="#660096">+</font><font color="#000000"> (y1 </font><font color="#660096">-</font><font color="#000000"> y2) </font><font color="#660096">*</font><font color="#000000"> (y1 </font><font color="#660096">-</font><font color="#000000"> y2))
      </font><font color="#0000aa">set</font><font color="#000000"> junc-point </font><font color="#660096">list</font><font color="#000000"> x2 y2
      </font><font color="#5a5a5a">;Decide the direction of the agent</font><font color="#000000">
      </font><font color="#0000aa">if</font><font color="#000000"> cur-length </font><font color="#660096">&gt;</font><font color="#000000"> junc-length
      [
        </font><font color="#0000aa">set</font><font color="#000000"> direction </font><font color="#963700">1</font><font color="#000000">                 </font><font color="#5a5a5a">;;0-no;1-from;2-to</font><font color="#000000">
      ]
      </font><font color="#0000aa">if</font><font color="#000000"> cur-length </font><font color="#660096">&lt;</font><font color="#000000"> junc-length
      [
        </font><font color="#0000aa">set</font><font color="#000000"> direction </font><font color="#963700">2</font><font color="#000000">
      ]
      </font><font color="#0000aa">if</font><font color="#000000"> cur-length </font><font color="#660096">=</font><font color="#000000"> junc-length
      [
        </font><font color="#0000aa">set</font><font color="#000000"> direction </font><font color="#963700">0</font><font color="#000000">
      ]
      </font><font color="#5a5a5a">;Set the red color for the destination street</font><font color="#000000">
</font><font color="#5a5a5a">;      ask link (item 0 (item cur-street streetdata)) (item 1 (item cur-street streetdata)) </font><font color="#000000">
</font><font color="#5a5a5a">;      [</font><font color="#000000">
</font><font color="#5a5a5a">;        set color white</font><font color="#000000">
</font><font color="#5a5a5a">;      ] </font><font color="#000000">
</font><font color="#5a5a5a">;      ask link (item 0 (item next-street streetdata)) (item 1 (item next-street streetdata)) </font><font color="#000000">
</font><font color="#5a5a5a">;      [</font><font color="#000000">
</font><font color="#5a5a5a">;        set color red</font><font color="#000000">
</font><font color="#5a5a5a">;      ]                  </font><font color="#000000">
      </font><font color="#0000aa">ifelse</font><font color="#000000"> direction </font><font color="#660096">=</font><font color="#000000"> </font><font color="#963700">0</font><font color="#000000">
      [
        </font><font color="#5a5a5a">;the agent return back to the last street</font><font color="#000000">
        </font><font color="#0000aa">set</font><font color="#000000"> last-street cur-street
        </font><font color="#0000aa">set</font><font color="#000000"> cur-street next-street
        </font><font color="#0000aa">set</font><font color="#000000"> next-street </font><font color="#963700">-1</font><font color="#000000">
        </font><font color="#0000aa">set</font><font color="#000000"> last-location junc-point
        </font><font color="#0000aa">set</font><font color="#000000"> junc-point (</font><font color="#660096">list</font><font color="#000000">)
        </font><font color="#0000aa">set</font><font color="#000000"> junc-length </font><font color="#963700">0</font><font color="#000000">
        </font><font color="#0000aa">let</font><font color="#000000"> x3 [</font><font color="#660096">xcor</font><font color="#000000">] </font><font color="#660096">of</font><font color="#000000"> (node (</font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000"> first-intersection-point)) </font><font color="#5a5a5a">;;get the xcor of the first node of the cur-street</font><font color="#000000">
        </font><font color="#0000aa">let</font><font color="#000000"> y3 [</font><font color="#660096">ycor</font><font color="#000000">] </font><font color="#660096">of</font><font color="#000000"> (node (</font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000"> first-intersection-point))
        </font><font color="#0000aa">set</font><font color="#000000"> cur-length </font><font color="#660096">sqrt</font><font color="#000000">((x3 </font><font color="#660096">-</font><font color="#000000"> x2) </font><font color="#660096">*</font><font color="#000000"> (x3 </font><font color="#660096">-</font><font color="#000000"> x2) </font><font color="#660096">+</font><font color="#000000"> (y3 </font><font color="#660096">-</font><font color="#000000"> y2) </font><font color="#660096">*</font><font color="#000000"> (y3 </font><font color="#660096">-</font><font color="#000000"> y2))
        move-agents-random </font><font color="#660096">who</font><font color="#000000">
      ]
      [
        move-agents-random </font><font color="#660096">who</font><font color="#000000">
      ]
    ]
  ]
</font><font color="#007f69">end</font><font color="#000000">
</font><font color="#5a5a5a">;Select the next street from its connected streets randomly with a priority on the most connected street based on the connectivity graph</font><font color="#000000">
</font><font color="#007f69">to-report</font><font color="#000000"> GetNextStreet [intersects-street pStreet1]
  </font><font color="#0000aa">let</font><font color="#000000"> pStreet2 </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">0</font><font color="#000000"> intersects-street
  </font><font color="#0000aa">ifelse</font><font color="#000000"> pStreet1 </font><font color="#660096">=</font><font color="#000000"> pStreet2
  [
    </font><font color="#0000aa">let</font><font color="#000000"> intersects-street-1 </font><font color="#660096">sublist</font><font color="#000000"> intersects-street </font><font color="#963700">1</font><font color="#000000"> (</font><font color="#660096">length</font><font color="#000000"> intersects-street)
    </font><font color="#0000aa">let</font><font color="#000000"> connectivitySum </font><font color="#963700">0</font><font color="#000000">
    </font><font color="#0000aa">foreach</font><font color="#000000"> intersects-street-1
    [
      </font><font color="#0000aa">let</font><font color="#000000"> street-id </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">0</font><font color="#000000"> ?
      </font><font color="#0000aa">set</font><font color="#000000"> connectivitySum connectivitySum </font><font color="#660096">+</font><font color="#000000"> </font><font color="#660096">length</font><font color="#000000">(</font><font color="#660096">item</font><font color="#000000"> street-id street-list) </font><font color="#660096">-</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000">
    ]
    </font><font color="#0000aa">let</font><font color="#000000"> random-connectivity </font><font color="#660096">random</font><font color="#000000"> connectivitySum
    </font><font color="#0000aa">let</font><font color="#000000"> cumulCon </font><font color="#963700">0</font><font color="#000000">  </font><font color="#5a5a5a">;cumulative connectivity</font><font color="#000000">
    </font><font color="#0000aa">foreach</font><font color="#000000"> intersects-street-1
    [
      </font><font color="#0000aa">let</font><font color="#000000"> street-id </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">0</font><font color="#000000"> ?
      </font><font color="#0000aa">if</font><font color="#000000"> ((random-connectivity </font><font color="#660096">&gt;=</font><font color="#000000"> cumulCon) </font><font color="#660096">and</font><font color="#000000"> (random-connectivity </font><font color="#660096">&lt;=</font><font color="#000000"> cumulCon </font><font color="#660096">+</font><font color="#000000"> (</font><font color="#660096">length</font><font color="#000000">(</font><font color="#660096">item</font><font color="#000000"> street-id street-list) </font><font color="#660096">-</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000">)))
      [
        </font><font color="#0000aa">report</font><font color="#000000"> ?
      ]
      </font><font color="#0000aa">set</font><font color="#000000"> cumulCon cumulCon </font><font color="#660096">+</font><font color="#000000"> </font><font color="#660096">length</font><font color="#000000">(</font><font color="#660096">item</font><font color="#000000"> street-id street-list) </font><font color="#660096">-</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000">
    ]
  ]
  [
    </font><font color="#0000aa">user-message</font><font color="#000000"> </font><font color="#963700">&quot;error in generating the Connectivity Graph!&quot;</font><font color="#000000">
    </font><font color="#0000aa">stop</font><font color="#000000"> 
  ]
</font><font color="#007f69">end</font><font color="#000000">
</font><font color="#5a5a5a">;Construct the connectivity graph</font><font color="#000000">
</font><font color="#007f69">to</font><font color="#000000"> ConstructConnectivityGraph
  </font><font color="#0000aa">ifelse</font><font color="#000000"> (</font><font color="#660096">length</font><font color="#000000"> streetdata) </font><font color="#660096">!=</font><font color="#000000"> </font><font color="#963700">0</font><font color="#000000">
  [
    </font><font color="#0000aa">let</font><font color="#000000"> k </font><font color="#963700">0</font><font color="#000000">
    </font><font color="#0000aa">set</font><font color="#000000"> street-list (</font><font color="#660096">list</font><font color="#000000">)
    </font><font color="#0000aa">foreach</font><font color="#000000"> streetdata
    [
      </font><font color="#0000aa">let</font><font color="#000000"> ele (</font><font color="#660096">list</font><font color="#000000"> k)
      </font><font color="#0000aa">set</font><font color="#000000"> street-list </font><font color="#660096">lput</font><font color="#000000"> ele street-list
      </font><font color="#0000aa">set</font><font color="#000000"> k k </font><font color="#660096">+</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000">
    ]
    </font><font color="#0000aa">set</font><font color="#000000"> countAbnormal (</font><font color="#660096">list</font><font color="#000000">)
    </font><font color="#0000aa">let</font><font color="#000000"> i </font><font color="#963700">0</font><font color="#000000">
    </font><font color="#0000aa">foreach</font><font color="#000000"> streetdata
    [
      </font><font color="#0000aa">let</font><font color="#000000"> street1 ?
      </font><font color="#0000aa">let</font><font color="#000000"> street-list-ele (</font><font color="#660096">item</font><font color="#000000"> i street-list)
      </font><font color="#0000aa">let</font><font color="#000000"> j </font><font color="#963700">0</font><font color="#000000">
      </font><font color="#0000aa">foreach</font><font color="#000000"> streetdata
      [
        </font><font color="#0000aa">let</font><font color="#000000"> street2 ? 
        </font><font color="#0000aa">if</font><font color="#000000"> i </font><font color="#660096">&lt;</font><font color="#000000"> j
        [
          </font><font color="#0000aa">let</font><font color="#000000"> intersection-list (</font><font color="#660096">list</font><font color="#000000"> j)
          </font><font color="#0000aa">let</font><font color="#000000"> point Intersection street1 street2
          </font><font color="#0000aa">if</font><font color="#000000"> </font><font color="#660096">not</font><font color="#000000"> </font><font color="#660096">empty?</font><font color="#000000"> point
          [
            </font><font color="#0000aa">let</font><font color="#000000"> point1 point
            </font><font color="#0000aa">set</font><font color="#000000"> point1 </font><font color="#660096">fput</font><font color="#000000"> (</font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">0</font><font color="#000000"> street2) point1
            </font><font color="#0000aa">set</font><font color="#000000"> point1 </font><font color="#660096">fput</font><font color="#000000"> (</font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">0</font><font color="#000000"> street1) point1
            </font><font color="#0000aa">set</font><font color="#000000"> intersection-list </font><font color="#660096">lput</font><font color="#000000"> point1 intersection-list
            </font><font color="#0000aa">set</font><font color="#000000"> street-list-ele </font><font color="#660096">lput</font><font color="#000000"> intersection-list street-list-ele
            
            </font><font color="#0000aa">let</font><font color="#000000"> street-list-ele-j (</font><font color="#660096">item</font><font color="#000000"> j street-list)
            </font><font color="#0000aa">let</font><font color="#000000"> point2 point
            </font><font color="#0000aa">set</font><font color="#000000"> point2 </font><font color="#660096">fput</font><font color="#000000"> (</font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">0</font><font color="#000000"> street1) point2
            </font><font color="#0000aa">set</font><font color="#000000"> point2 </font><font color="#660096">fput</font><font color="#000000"> (</font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">0</font><font color="#000000"> street2) point2
            </font><font color="#0000aa">let</font><font color="#000000"> intersection-list-j (</font><font color="#660096">list</font><font color="#000000"> i)
            </font><font color="#0000aa">set</font><font color="#000000"> intersection-list-j </font><font color="#660096">lput</font><font color="#000000"> point2 intersection-list-j
            </font><font color="#0000aa">set</font><font color="#000000"> street-list-ele-j </font><font color="#660096">lput</font><font color="#000000"> intersection-list-j street-list-ele-j
            </font><font color="#0000aa">set</font><font color="#000000"> street-list </font><font color="#660096">replace-item</font><font color="#000000"> j street-list street-list-ele-j
          ]
        ]
        </font><font color="#0000aa">set</font><font color="#000000"> j j </font><font color="#660096">+</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000">
      ]
      </font><font color="#0000aa">if</font><font color="#000000"> (</font><font color="#660096">length</font><font color="#000000"> street-list-ele)</font><font color="#660096">=</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000">
      [
        </font><font color="#0000aa">set</font><font color="#000000"> countAbnormal </font><font color="#660096">lput</font><font color="#000000"> street-list-ele countAbnormal
      ]     
      </font><font color="#0000aa">show</font><font color="#000000"> street-list-ele
      </font><font color="#0000aa">set</font><font color="#000000"> street-list </font><font color="#660096">replace-item</font><font color="#000000"> i street-list street-list-ele    
      </font><font color="#0000aa">set</font><font color="#000000"> i i </font><font color="#660096">+</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000">
    ]
    </font><font color="#0000aa">show</font><font color="#000000"> street-list
    </font><font color="#0000aa">show</font><font color="#000000"> countAbnormal
  ]
  [
    </font><font color="#0000aa">user-message</font><font color="#000000"> </font><font color="#963700">&quot;please load street first!&quot;</font><font color="#000000">
    </font><font color="#0000aa">stop</font><font color="#000000"> 
  ]
</font><font color="#007f69">end</font><font color="#000000">
</font><font color="#5a5a5a">;Get the intersection of two axial line</font><font color="#000000">
</font><font color="#007f69">to-report</font><font color="#000000"> Intersection [street1 street2]
  </font><font color="#0000aa">let</font><font color="#000000"> x-s1 </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">2</font><font color="#000000"> street1
  </font><font color="#0000aa">let</font><font color="#000000"> y-s1 </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">3</font><font color="#000000"> street1
  </font><font color="#0000aa">let</font><font color="#000000"> x-e1 </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">4</font><font color="#000000"> street1
  </font><font color="#0000aa">let</font><font color="#000000"> y-e1 </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">5</font><font color="#000000"> street1
  </font><font color="#0000aa">let</font><font color="#000000"> x-s2 </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">2</font><font color="#000000"> street2
  </font><font color="#0000aa">let</font><font color="#000000"> y-s2 </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">3</font><font color="#000000"> street2
  </font><font color="#0000aa">let</font><font color="#000000"> x-e2 </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">4</font><font color="#000000"> street2
  </font><font color="#0000aa">let</font><font color="#000000"> y-e2 </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">5</font><font color="#000000"> street2
  </font><font color="#0000aa">let</font><font color="#000000"> x1-min </font><font color="#963700">0</font><font color="#000000">
  </font><font color="#0000aa">let</font><font color="#000000"> x1-max </font><font color="#963700">0</font><font color="#000000">
  </font><font color="#0000aa">let</font><font color="#000000"> y1-min </font><font color="#963700">0</font><font color="#000000">
  </font><font color="#0000aa">let</font><font color="#000000"> y1-max </font><font color="#963700">0</font><font color="#000000">
  </font><font color="#0000aa">let</font><font color="#000000"> x2-min </font><font color="#963700">0</font><font color="#000000">
  </font><font color="#0000aa">let</font><font color="#000000"> x2-max </font><font color="#963700">0</font><font color="#000000">
  </font><font color="#0000aa">let</font><font color="#000000"> y2-min </font><font color="#963700">0</font><font color="#000000">
  </font><font color="#0000aa">let</font><font color="#000000"> y2-max </font><font color="#963700">0</font><font color="#000000">
  </font><font color="#0000aa">ifelse</font><font color="#000000"> x-s1 </font><font color="#660096">&gt;</font><font color="#000000"> x-e1
  [ </font><font color="#0000aa">set</font><font color="#000000"> x1-min x-e1
    </font><font color="#0000aa">set</font><font color="#000000"> x1-max x-s1
  ]
  [ </font><font color="#0000aa">set</font><font color="#000000"> x1-min x-s1
    </font><font color="#0000aa">set</font><font color="#000000"> x1-max x-e1
  ]
  </font><font color="#0000aa">ifelse</font><font color="#000000"> y-s1 </font><font color="#660096">&gt;</font><font color="#000000"> y-e1
  [ </font><font color="#0000aa">set</font><font color="#000000"> y1-min y-e1
    </font><font color="#0000aa">set</font><font color="#000000"> y1-max y-s1
  ]
  [ </font><font color="#0000aa">set</font><font color="#000000"> y1-min y-s1
    </font><font color="#0000aa">set</font><font color="#000000"> y1-max y-e1
  ]
  </font><font color="#0000aa">ifelse</font><font color="#000000"> x-s2 </font><font color="#660096">&gt;</font><font color="#000000"> x-e2
  [ </font><font color="#0000aa">set</font><font color="#000000"> x2-min x-e2
    </font><font color="#0000aa">set</font><font color="#000000"> x2-max x-s2
  ]
  [ </font><font color="#0000aa">set</font><font color="#000000"> x2-min x-s2
    </font><font color="#0000aa">set</font><font color="#000000"> x2-max x-e2
  ]
  </font><font color="#0000aa">ifelse</font><font color="#000000"> y-s2 </font><font color="#660096">&gt;</font><font color="#000000"> y-e2
  [ </font><font color="#0000aa">set</font><font color="#000000"> y2-min y-e2
    </font><font color="#0000aa">set</font><font color="#000000"> y2-max y-s2
  ]
  [ </font><font color="#0000aa">set</font><font color="#000000"> y2-min y-s2
    </font><font color="#0000aa">set</font><font color="#000000"> y2-max y-e2
  ]
  </font><font color="#0000aa">ifelse</font><font color="#000000"> ((x1-min </font><font color="#660096">&gt;</font><font color="#000000"> x2-max) </font><font color="#660096">or</font><font color="#000000"> (x2-min </font><font color="#660096">&gt;</font><font color="#000000"> x1-max) </font><font color="#660096">or</font><font color="#000000"> (y1-min </font><font color="#660096">&gt;</font><font color="#000000"> y2-max) </font><font color="#660096">or</font><font color="#000000"> (y2-min </font><font color="#660096">&gt;</font><font color="#000000"> y1-max))
  [
    </font><font color="#0000aa">report</font><font color="#000000"> []
  ]
  [
    </font><font color="#0000aa">let</font><font color="#000000"> m1 </font><font color="#963700">0</font><font color="#000000">
    </font><font color="#0000aa">let</font><font color="#000000"> m2 </font><font color="#963700">0</font><font color="#000000">
    </font><font color="#0000aa">if</font><font color="#000000"> x-s1 </font><font color="#660096">=</font><font color="#000000"> x-e1
    [
      </font><font color="#0000aa">ifelse</font><font color="#000000"> x-s2 </font><font color="#660096">=</font><font color="#000000"> x-e2
      [</font><font color="#0000aa">report</font><font color="#000000"> [] ]
      [
        </font><font color="#0000aa">report</font><font color="#000000"> Intersection street2 street1
      ]
    ]
    </font><font color="#0000aa">if</font><font color="#000000"> x-s2 </font><font color="#660096">=</font><font color="#000000"> x-e2
    [
      </font><font color="#0000aa">set</font><font color="#000000"> m1 (y-e1 </font><font color="#660096">-</font><font color="#000000"> y-s1) </font><font color="#660096">/</font><font color="#000000"> (x-e1 </font><font color="#660096">-</font><font color="#000000"> x-s1)
      </font><font color="#0000aa">let</font><font color="#000000"> c1 (y-s1 </font><font color="#660096">-</font><font color="#000000"> m1 </font><font color="#660096">*</font><font color="#000000"> x-s1)
      </font><font color="#0000aa">let</font><font color="#000000"> x x-s2
      </font><font color="#0000aa">let</font><font color="#000000"> y m1 </font><font color="#660096">*</font><font color="#000000"> x </font><font color="#660096">+</font><font color="#000000"> c1
      </font><font color="#0000aa">if</font><font color="#000000"> </font><font color="#660096">not</font><font color="#000000"> x-within? x x-s1 x-e1 [ </font><font color="#0000aa">report</font><font color="#000000"> [] ]
      </font><font color="#0000aa">if</font><font color="#000000"> </font><font color="#660096">not</font><font color="#000000"> y-within? y y-s2 y-e2 [ </font><font color="#0000aa">report</font><font color="#000000"> [] ]
      </font><font color="#0000aa">report</font><font color="#000000"> </font><font color="#660096">list</font><font color="#000000"> x y
    ]
    </font><font color="#0000aa">set</font><font color="#000000"> m2 (y-e2 </font><font color="#660096">-</font><font color="#000000"> y-s2) </font><font color="#660096">/</font><font color="#000000"> (x-e2 </font><font color="#660096">-</font><font color="#000000"> x-s2)
    </font><font color="#0000aa">set</font><font color="#000000"> m1 (y-e1 </font><font color="#660096">-</font><font color="#000000"> y-s1) </font><font color="#660096">/</font><font color="#000000"> (x-e1 </font><font color="#660096">-</font><font color="#000000"> x-s1)
    </font><font color="#0000aa">if</font><font color="#000000"> m1 </font><font color="#660096">=</font><font color="#000000"> m2
    [</font><font color="#0000aa">report</font><font color="#000000"> []]
    </font><font color="#0000aa">let</font><font color="#000000"> c1 (y-s1 </font><font color="#660096">-</font><font color="#000000"> m1 </font><font color="#660096">*</font><font color="#000000"> x-s1)
    </font><font color="#0000aa">let</font><font color="#000000"> c2 (y-s2 </font><font color="#660096">-</font><font color="#000000"> m2 </font><font color="#660096">*</font><font color="#000000"> x-s2)
    </font><font color="#0000aa">let</font><font color="#000000"> x (c2 </font><font color="#660096">-</font><font color="#000000"> c1) </font><font color="#660096">/</font><font color="#000000"> (m1 </font><font color="#660096">-</font><font color="#000000"> m2)
    </font><font color="#5a5a5a">;; check if intersection point lies on both segments</font><font color="#000000">
    </font><font color="#0000aa">if</font><font color="#000000"> </font><font color="#660096">not</font><font color="#000000"> x-within? x x-s1 x-e1 [ </font><font color="#0000aa">report</font><font color="#000000"> [] ]
    </font><font color="#0000aa">if</font><font color="#000000"> </font><font color="#660096">not</font><font color="#000000"> x-within? x x-s2 x-e2 [ </font><font color="#0000aa">report</font><font color="#000000"> [] ]
    </font><font color="#0000aa">report</font><font color="#000000"> </font><font color="#660096">list</font><font color="#000000"> x (m1 </font><font color="#660096">*</font><font color="#000000"> x </font><font color="#660096">+</font><font color="#000000"> c1)
  ]
</font><font color="#007f69">end</font><font color="#000000">
</font><font color="#5a5a5a">;To judge if x lies within the scope of x1 and x2</font><font color="#000000">
</font><font color="#007f69">to-report</font><font color="#000000"> x-within? [x x1 x2]  
  </font><font color="#0000aa">let</font><font color="#000000"> w </font><font color="#660096">abs</font><font color="#000000">(x1 </font><font color="#660096">-</font><font color="#000000"> x2)
  </font><font color="#0000aa">let</font><font color="#000000"> mid (x1 </font><font color="#660096">+</font><font color="#000000"> x2) </font><font color="#660096">/</font><font color="#000000"> </font><font color="#963700">2</font><font color="#000000">
  </font><font color="#0000aa">set</font><font color="#000000"> w w </font><font color="#660096">/</font><font color="#000000"> </font><font color="#963700">2</font><font color="#000000">
  </font><font color="#0000aa">report</font><font color="#000000"> </font><font color="#660096">abs</font><font color="#000000"> (mid </font><font color="#660096">-</font><font color="#000000"> x) </font><font color="#660096">&lt;=</font><font color="#000000"> w
</font><font color="#007f69">end</font><font color="#000000">
</font><font color="#5a5a5a">;To judge if y lies within the scope of y1 and y2</font><font color="#000000">
</font><font color="#007f69">to-report</font><font color="#000000"> y-within? [y y1 y2]  
  </font><font color="#0000aa">let</font><font color="#000000"> w </font><font color="#660096">abs</font><font color="#000000">(y1 </font><font color="#660096">-</font><font color="#000000"> y2)
  </font><font color="#0000aa">let</font><font color="#000000"> mid (y1 </font><font color="#660096">+</font><font color="#000000"> y2) </font><font color="#660096">/</font><font color="#000000"> </font><font color="#963700">2</font><font color="#000000">
  </font><font color="#0000aa">set</font><font color="#000000"> w w </font><font color="#660096">/</font><font color="#000000"> </font><font color="#963700">2</font><font color="#000000">
  </font><font color="#0000aa">report</font><font color="#000000"> </font><font color="#660096">abs</font><font color="#000000"> (mid </font><font color="#660096">-</font><font color="#000000"> y) </font><font color="#660096">&lt;=</font><font color="#000000"> w
</font><font color="#007f69">end</font><font color="#000000">
</font><font color="#5a5a5a">;Compute the shortest distance path between the current location and destination</font><font color="#000000">
</font><font color="#5a5a5a">;report the data format like [0,[streetID1,x1,y1,x1,y1]]  VS  [1,[streetID1,x1,y1,x2,y2],[streetID2,x1,y1,x2,y2],[streetID3,x1,y1,x2,y2]] NOTE,1 indicates that there is at least one path, But 0 indicates that the OD point are identical, So there exists no path.</font><font color="#000000">
</font><font color="#007f69">to-report</font><font color="#000000"> GetPath[x1 y1 street1 x2 y2 street2]  
  </font><font color="#0000aa">if</font><font color="#000000"> street1 </font><font color="#660096">=</font><font color="#000000"> street2
  [
    </font><font color="#0000aa">let</font><font color="#000000"> lineInfo sudLine street1 x1 y1 x2 y2
    </font><font color="#0000aa">report</font><font color="#000000"> lineInfo
  ]
  </font><font color="#0000aa">let</font><font color="#000000"> topoDist </font><font color="#963700">0</font><font color="#000000">
  </font><font color="#0000aa">let</font><font color="#000000"> geoDist </font><font color="#963700">1000000000</font><font color="#000000">
  </font><font color="#0000aa">let</font><font color="#000000"> flag TopoShortestPath street1 street2
  </font><font color="#0000aa">ifelse</font><font color="#000000"> flag </font><font color="#660096">=</font><font color="#000000"> </font><font color="#963700">true</font><font color="#000000">
  [
    </font><font color="#0000aa">let</font><font color="#000000"> currPathDist </font><font color="#963700">0</font><font color="#000000">
    </font><font color="#0000aa">let</font><font color="#000000"> minPathIdx </font><font color="#963700">-1</font><font color="#000000">
    </font><font color="#0000aa">let</font><font color="#000000"> i </font><font color="#963700">0</font><font color="#000000">
    </font><font color="#0000aa">foreach</font><font color="#000000"> pathIDsList
    [
      </font><font color="#0000aa">set</font><font color="#000000"> currPathDist pathDist ? x1 y1 street1 x2 y2 street2
      </font><font color="#0000aa">if</font><font color="#000000"> currPathDist </font><font color="#660096">&lt;</font><font color="#000000"> geoDist
      [
        </font><font color="#0000aa">set</font><font color="#000000"> geoDist currPathDist
        </font><font color="#0000aa">set</font><font color="#000000"> minPathIdx i
      ]
      </font><font color="#0000aa">set</font><font color="#000000"> i i </font><font color="#660096">+</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000">
    ]
    </font><font color="#0000aa">let</font><font color="#000000"> pathStr </font><font color="#660096">item</font><font color="#000000"> minPathIdx pathIDsList
    </font><font color="#0000aa">let</font><font color="#000000"> myResult pathDistOutput pathStr x1 y1 street1 x2 y2 street2
    </font><font color="#0000aa">set</font><font color="#000000"> myResult </font><font color="#660096">fput</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000"> myResult
    </font><font color="#0000aa">report</font><font color="#000000"> myResult
  ]
  [
     </font><font color="#0000aa">user-message</font><font color="#000000"> </font><font color="#963700">&quot;Exist Isolation in the StreetNetwork!&quot;</font><font color="#000000">
     </font><font color="#0000aa">stop</font><font color="#000000"> 
  ]
</font><font color="#007f69">end</font><font color="#000000">
</font><font color="#007f69">to-report</font><font color="#000000"> pathDistOutput [pathStr x1 y1 street1 x2 y2 street2]
  </font><font color="#0000aa">let</font><font color="#000000"> lineInfo (</font><font color="#660096">list</font><font color="#000000">)
  
  </font><font color="#0000aa">let</font><font color="#000000"> currPt (</font><font color="#660096">list</font><font color="#000000"> x1 y1)
  </font><font color="#0000aa">let</font><font color="#000000"> nxtPt (</font><font color="#660096">list</font><font color="#000000">)
  </font><font color="#0000aa">let</font><font color="#000000"> currFID street1
  </font><font color="#0000aa">let</font><font color="#000000"> nxtFID </font><font color="#963700">-1</font><font color="#000000">
  </font><font color="#0000aa">let</font><font color="#000000"> commaIdx </font><font color="#660096">position</font><font color="#000000"> </font><font color="#963700">&quot;,&quot;</font><font color="#000000"> pathStr
  </font><font color="#0000aa">set</font><font color="#000000"> pathStr </font><font color="#660096">substring</font><font color="#000000"> pathStr (commaIdx) (</font><font color="#660096">length</font><font color="#000000"> pathStr)
  
  </font><font color="#0000aa">while</font><font color="#000000"> [(</font><font color="#660096">position</font><font color="#000000"> </font><font color="#963700">&quot;,&quot;</font><font color="#000000"> pathStr) </font><font color="#660096">!=</font><font color="#000000"> </font><font color="#963700">false</font><font color="#000000">]
  [
    </font><font color="#0000aa">set</font><font color="#000000"> pathStr </font><font color="#660096">remove-item</font><font color="#000000"> </font><font color="#963700">0</font><font color="#000000"> pathStr
    </font><font color="#0000aa">set</font><font color="#000000"> commaIdx </font><font color="#660096">position</font><font color="#000000"> </font><font color="#963700">&quot;,&quot;</font><font color="#000000"> pathStr
    </font><font color="#0000aa">ifelse</font><font color="#000000"> commaIdx </font><font color="#660096">=</font><font color="#000000"> </font><font color="#963700">false</font><font color="#000000">
    [
      </font><font color="#0000aa">set</font><font color="#000000"> nxtFID </font><font color="#660096">read-from-string</font><font color="#000000"> pathStr
    ]
    [
      </font><font color="#0000aa">set</font><font color="#000000"> nxtFID </font><font color="#660096">read-from-string</font><font color="#000000"> (</font><font color="#660096">substring</font><font color="#000000"> pathStr </font><font color="#963700">0</font><font color="#000000"> commaIdx)
    ]
    </font><font color="#0000aa">let</font><font color="#000000"> streetF </font><font color="#660096">item</font><font color="#000000"> currFID streetdata
    </font><font color="#0000aa">let</font><font color="#000000"> streetT </font><font color="#660096">item</font><font color="#000000"> nxtFID streetdata
    </font><font color="#0000aa">set</font><font color="#000000"> nxtPt Intersection streetF streetT
    
    </font><font color="#0000aa">set</font><font color="#000000"> lineInfo </font><font color="#660096">lput</font><font color="#000000"> (</font><font color="#660096">list</font><font color="#000000"> currFID (</font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">0</font><font color="#000000"> currPt) (</font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000"> currPt) (</font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">0</font><font color="#000000"> nxtPt) (</font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000"> nxtPt)) lineInfo
    
    </font><font color="#0000aa">set</font><font color="#000000"> currFID nxtFID
    </font><font color="#0000aa">set</font><font color="#000000"> currPt nxtPt
    </font><font color="#0000aa">if</font><font color="#000000"> commaIdx </font><font color="#660096">!=</font><font color="#000000"> </font><font color="#963700">false</font><font color="#000000">
    [
      </font><font color="#0000aa">set</font><font color="#000000"> pathStr </font><font color="#660096">substring</font><font color="#000000"> pathStr commaIdx (</font><font color="#660096">length</font><font color="#000000"> pathStr)
    ]
  ]
  </font><font color="#0000aa">set</font><font color="#000000"> lineInfo </font><font color="#660096">lput</font><font color="#000000"> (</font><font color="#660096">list</font><font color="#000000"> nxtFID (</font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">0</font><font color="#000000"> nxtPt) (</font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000"> nxtPt) x2 y2) lineInfo
  </font><font color="#0000aa">report</font><font color="#000000"> lineInfo
</font><font color="#007f69">end</font><font color="#000000">
</font><font color="#007f69">to-report</font><font color="#000000"> pathDist [pathStr x1 y1 street1 x2 y2 street2]
    
  </font><font color="#0000aa">let</font><font color="#000000"> currPt (</font><font color="#660096">list</font><font color="#000000"> x1 y1)
  </font><font color="#0000aa">let</font><font color="#000000"> nxtPt (</font><font color="#660096">list</font><font color="#000000">)
  </font><font color="#0000aa">let</font><font color="#000000"> currFID street1
  </font><font color="#0000aa">let</font><font color="#000000"> nxtFID </font><font color="#963700">-1</font><font color="#000000">
  </font><font color="#0000aa">let</font><font color="#000000"> commaIdx </font><font color="#660096">position</font><font color="#000000"> </font><font color="#963700">&quot;,&quot;</font><font color="#000000"> pathStr
  </font><font color="#0000aa">set</font><font color="#000000"> pathStr </font><font color="#660096">substring</font><font color="#000000"> pathStr (commaIdx) (</font><font color="#660096">length</font><font color="#000000"> pathStr)
  
  </font><font color="#0000aa">let</font><font color="#000000"> rtnDist </font><font color="#963700">0</font><font color="#000000">
  </font><font color="#0000aa">while</font><font color="#000000"> [(</font><font color="#660096">position</font><font color="#000000"> </font><font color="#963700">&quot;,&quot;</font><font color="#000000"> pathStr) </font><font color="#660096">!=</font><font color="#000000"> </font><font color="#963700">false</font><font color="#000000">]
  [
    </font><font color="#0000aa">set</font><font color="#000000"> pathStr </font><font color="#660096">remove-item</font><font color="#000000"> </font><font color="#963700">0</font><font color="#000000"> pathStr
    </font><font color="#0000aa">set</font><font color="#000000"> commaIdx </font><font color="#660096">position</font><font color="#000000"> </font><font color="#963700">&quot;,&quot;</font><font color="#000000"> pathStr
    </font><font color="#0000aa">ifelse</font><font color="#000000"> commaIdx </font><font color="#660096">=</font><font color="#000000"> </font><font color="#963700">false</font><font color="#000000">
    [
      </font><font color="#0000aa">set</font><font color="#000000"> nxtFID </font><font color="#660096">read-from-string</font><font color="#000000"> pathStr
    ]
    [
      </font><font color="#0000aa">set</font><font color="#000000"> nxtFID </font><font color="#660096">read-from-string</font><font color="#000000"> (</font><font color="#660096">substring</font><font color="#000000"> pathStr </font><font color="#963700">0</font><font color="#000000"> commaIdx)
    ]
    </font><font color="#0000aa">let</font><font color="#000000"> streetF </font><font color="#660096">item</font><font color="#000000"> currFID streetdata
    </font><font color="#0000aa">let</font><font color="#000000"> streetT </font><font color="#660096">item</font><font color="#000000"> nxtFID streetdata
    </font><font color="#0000aa">set</font><font color="#000000"> nxtPt Intersection streetF streetT
    
    </font><font color="#0000aa">let</font><font color="#000000"> mydist GetMyDist currPt nxtPt
    </font><font color="#0000aa">set</font><font color="#000000"> rtnDist (rtnDist </font><font color="#660096">+</font><font color="#000000"> mydist)
    
    </font><font color="#0000aa">set</font><font color="#000000"> currFID nxtFID
    </font><font color="#0000aa">set</font><font color="#000000"> currPt nxtPt
    </font><font color="#0000aa">if</font><font color="#000000"> commaIdx </font><font color="#660096">!=</font><font color="#000000"> </font><font color="#963700">false</font><font color="#000000">
    [
      </font><font color="#0000aa">set</font><font color="#000000"> pathStr </font><font color="#660096">substring</font><font color="#000000"> pathStr commaIdx (</font><font color="#660096">length</font><font color="#000000"> pathStr)
    ]
  ]
  </font><font color="#0000aa">let</font><font color="#000000"> mydist1 GetMyDist nxtPt (</font><font color="#660096">list</font><font color="#000000"> x2 y2)
  </font><font color="#0000aa">set</font><font color="#000000"> rtnDist (rtnDist </font><font color="#660096">+</font><font color="#000000"> mydist1)
  </font><font color="#0000aa">report</font><font color="#000000"> rtnDist
</font><font color="#007f69">end</font><font color="#000000">
</font><font color="#007f69">to-report</font><font color="#000000"> GetMyDist [pt1 pt2]
  </font><font color="#0000aa">let</font><font color="#000000"> x1 </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">0</font><font color="#000000"> pt1
  </font><font color="#0000aa">let</font><font color="#000000"> y1 </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000"> pt1
  </font><font color="#0000aa">let</font><font color="#000000"> x2 </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">0</font><font color="#000000"> pt2
  </font><font color="#0000aa">let</font><font color="#000000"> y2 </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000"> pt2
  
  </font><font color="#0000aa">report</font><font color="#000000"> </font><font color="#660096">sqrt</font><font color="#000000">((x1 </font><font color="#660096">-</font><font color="#000000"> x2)</font><font color="#660096">*</font><font color="#000000">(x1 </font><font color="#660096">-</font><font color="#000000"> x2)</font><font color="#660096">+</font><font color="#000000">(y1 </font><font color="#660096">-</font><font color="#000000"> y2)</font><font color="#660096">*</font><font color="#000000">(y1 </font><font color="#660096">-</font><font color="#000000"> y2))
</font><font color="#007f69">end</font><font color="#000000">
</font><font color="#007f69">to-report</font><font color="#000000"> TopoShortestPath [streetO streetD]
  </font><font color="#0000aa">set</font><font color="#000000"> pathList (</font><font color="#660096">list</font><font color="#000000">)
  </font><font color="#0000aa">set</font><font color="#000000"> pathIDsList (</font><font color="#660096">list</font><font color="#000000">)
  TopoSteps streetO
  </font><font color="#0000aa">let</font><font color="#000000"> topoDist </font><font color="#660096">item</font><font color="#000000"> streetD currLineDepth
  </font><font color="#0000aa">set</font><font color="#000000"> degree </font><font color="#660096">item</font><font color="#000000"> streetD currLineDepth
  </font><font color="#0000aa">if</font><font color="#000000"> degree </font><font color="#660096">=</font><font color="#000000"> </font><font color="#963700">0</font><font color="#000000">
  [
    </font><font color="#0000aa">report</font><font color="#000000"> </font><font color="#963700">false</font><font color="#000000">
  ]
  </font><font color="#0000aa">if</font><font color="#000000"> degree </font><font color="#660096">=</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000">
  [
    </font><font color="#0000aa">if</font><font color="#000000"> isConnect? streetO streetD
    [
      </font><font color="#0000aa">let</font><font color="#000000"> pathString (</font><font color="#660096">word</font><font color="#000000"> streetO </font><font color="#963700">&quot;,&quot;</font><font color="#000000"> streetD)
      </font><font color="#0000aa">set</font><font color="#000000"> pathIDsList </font><font color="#660096">lput</font><font color="#000000"> pathString pathIDsList
    ]
    </font><font color="#0000aa">report</font><font color="#000000"> </font><font color="#963700">true</font><font color="#000000">
  ]
  </font><font color="#0000aa">let</font><font color="#000000"> j </font><font color="#963700">0</font><font color="#000000">
  </font><font color="#0000aa">while</font><font color="#000000"> [j </font><font color="#660096">&lt;</font><font color="#000000"> degree </font><font color="#660096">-</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000">]
  [
    </font><font color="#0000aa">set</font><font color="#000000"> pathList </font><font color="#660096">lput</font><font color="#000000"> (</font><font color="#660096">list</font><font color="#000000">) pathList  </font><font color="#5a5a5a">;pathList [[],[],[],...]</font><font color="#000000">
    </font><font color="#0000aa">set</font><font color="#000000"> j j </font><font color="#660096">+</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000">
  ]
  </font><font color="#0000aa">let</font><font color="#000000"> i </font><font color="#963700">0</font><font color="#000000">
  </font><font color="#0000aa">set</font><font color="#000000"> j </font><font color="#963700">1</font><font color="#000000">
  </font><font color="#0000aa">let</font><font color="#000000"> numFeatures </font><font color="#660096">length</font><font color="#000000"> currLineDepth
  </font><font color="#0000aa">while</font><font color="#000000"> [i </font><font color="#660096">&lt;</font><font color="#000000"> numFeatures]
  [
    </font><font color="#0000aa">let</font><font color="#000000"> curDegree </font><font color="#660096">item</font><font color="#000000"> i currLineDepth
    </font><font color="#0000aa">if</font><font color="#000000"> curDegree </font><font color="#660096">&lt;</font><font color="#000000"> degree
    [
      </font><font color="#0000aa">set</font><font color="#000000"> j </font><font color="#963700">1</font><font color="#000000">
      </font><font color="#0000aa">while</font><font color="#000000"> [j </font><font color="#660096">&lt;</font><font color="#000000"> degree]
      [
        </font><font color="#0000aa">if</font><font color="#000000"> curDegree </font><font color="#660096">=</font><font color="#000000"> j
        [
          </font><font color="#0000aa">let</font><font color="#000000"> pathList-ele </font><font color="#660096">item</font><font color="#000000"> (j </font><font color="#660096">-</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000">) pathList
          </font><font color="#0000aa">set</font><font color="#000000"> pathList-ele </font><font color="#660096">lput</font><font color="#000000"> i pathList-ele
          </font><font color="#0000aa">set</font><font color="#000000"> pathList </font><font color="#660096">replace-item</font><font color="#000000"> (j </font><font color="#660096">-</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000">) pathList pathList-ele
        ]
        </font><font color="#0000aa">set</font><font color="#000000"> j j </font><font color="#660096">+</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000">
      ]
    ]
    </font><font color="#0000aa">set</font><font color="#000000"> i i </font><font color="#660096">+</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000">
  ]
  
  </font><font color="#0000aa">let</font><font color="#000000"> validPathIDList (</font><font color="#660096">list</font><font color="#000000">)
  </font><font color="#0000aa">set</font><font color="#000000"> validPathIDList </font><font color="#660096">lput</font><font color="#000000"> streetD validPathIDList
  filterPath validPathIDList
  
  </font><font color="#0000aa">set</font><font color="#000000"> currPath (</font><font color="#660096">word</font><font color="#000000"> streetO </font><font color="#963700">&quot;,&quot;</font><font color="#000000">)
  </font><font color="#0000aa">set</font><font color="#000000"> currDegree </font><font color="#963700">0</font><font color="#000000">
  </font><font color="#0000aa">let</font><font color="#000000"> localDegree </font><font color="#660096">item</font><font color="#000000"> streetD currLineDepth
  buildPath streetO streetD localDegree
  
  </font><font color="#0000aa">report</font><font color="#000000"> </font><font color="#963700">true</font><font color="#000000">
</font><font color="#007f69">end</font><font color="#000000">
</font><font color="#007f69">to</font><font color="#000000"> buildPath [currFID endFID localDegree]
  </font><font color="#0000aa">let</font><font color="#000000"> currDegreeList </font><font color="#660096">item</font><font color="#000000"> currDegree pathList
  </font><font color="#0000aa">foreach</font><font color="#000000"> currDegreeList
  [
    </font><font color="#0000aa">let</font><font color="#000000"> nxtFID ?
    </font><font color="#0000aa">if</font><font color="#000000"> isConnect? currFID nxtFID
    [
      </font><font color="#0000aa">set</font><font color="#000000"> currPath (</font><font color="#660096">word</font><font color="#000000"> currPath nxtFID </font><font color="#963700">&quot;,&quot;</font><font color="#000000">)
      </font><font color="#0000aa">ifelse</font><font color="#000000"> currDegree </font><font color="#660096">&lt;</font><font color="#000000"> (localDegree </font><font color="#660096">-</font><font color="#000000"> </font><font color="#963700">2</font><font color="#000000">)
      [
        </font><font color="#0000aa">set</font><font color="#000000"> currDegree currDegree </font><font color="#660096">+</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000">
        buildPath nxtFID endFID localDegree
      ]
      [
        </font><font color="#0000aa">set</font><font color="#000000"> pathIDsList </font><font color="#660096">lput</font><font color="#000000"> (</font><font color="#660096">word</font><font color="#000000"> currPath endFID) pathIDsList
      ]
      </font><font color="#0000aa">set</font><font color="#000000"> currPath </font><font color="#660096">remove-item</font><font color="#000000"> ((</font><font color="#660096">length</font><font color="#000000"> currPath)</font><font color="#660096">-</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000">) currPath
      </font><font color="#0000aa">let</font><font color="#000000"> reverseCurrPath </font><font color="#660096">reverse</font><font color="#000000"> currPath
      </font><font color="#0000aa">let</font><font color="#000000"> lastCommaIndex </font><font color="#660096">position</font><font color="#000000"> </font><font color="#963700">&quot;,&quot;</font><font color="#000000"> reverseCurrPath
      </font><font color="#0000aa">let</font><font color="#000000"> lastPosition (</font><font color="#660096">length</font><font color="#000000"> currPath) </font><font color="#660096">-</font><font color="#000000"> lastCommaIndex
      </font><font color="#0000aa">set</font><font color="#000000"> currPath </font><font color="#660096">substring</font><font color="#000000"> currPath </font><font color="#963700">0</font><font color="#000000"> lastPosition 
    ]
  ]
  </font><font color="#0000aa">set</font><font color="#000000"> currDegree currDegree </font><font color="#660096">-</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000">
</font><font color="#007f69">end</font><font color="#000000">
</font><font color="#007f69">to</font><font color="#000000"> filterPath [validPathIDList]
  </font><font color="#0000aa">let</font><font color="#000000"> tempDegreeList </font><font color="#660096">item</font><font color="#000000"> (degree </font><font color="#660096">-</font><font color="#000000"> </font><font color="#963700">2</font><font color="#000000">) pathList
  </font><font color="#0000aa">let</font><font color="#000000"> tmpValidList (</font><font color="#660096">list</font><font color="#000000">)
  </font><font color="#0000aa">foreach</font><font color="#000000"> validPathIDList
  [
    </font><font color="#0000aa">let</font><font color="#000000"> validPathId ?
    </font><font color="#0000aa">let</font><font color="#000000"> currFeatConn </font><font color="#660096">item</font><font color="#000000"> validPathId street-list
    </font><font color="#0000aa">set</font><font color="#000000"> currFeatConn </font><font color="#660096">sublist</font><font color="#000000"> currFeatConn </font><font color="#963700">1</font><font color="#000000"> (</font><font color="#660096">length</font><font color="#000000"> currFeatConn)
    </font><font color="#0000aa">foreach</font><font color="#000000"> currFeatConn
    [
      </font><font color="#0000aa">let</font><font color="#000000"> mID </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">0</font><font color="#000000"> ?
      </font><font color="#0000aa">if</font><font color="#000000"> </font><font color="#660096">member?</font><font color="#000000"> mID tempDegreeList
      [
        </font><font color="#0000aa">if</font><font color="#000000"> </font><font color="#660096">not</font><font color="#000000"> </font><font color="#660096">member?</font><font color="#000000"> mID tmpValidList
        [
          </font><font color="#0000aa">set</font><font color="#000000"> tmpValidList </font><font color="#660096">lput</font><font color="#000000"> mID tmpValidList
        ]
      ]
    ]
  ]
  </font><font color="#0000aa">set</font><font color="#000000"> pathList </font><font color="#660096">replace-item</font><font color="#000000"> (degree </font><font color="#660096">-</font><font color="#000000"> </font><font color="#963700">2</font><font color="#000000">) pathList tmpValidList
  </font><font color="#0000aa">set</font><font color="#000000"> degree degree </font><font color="#660096">-</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000">
  </font><font color="#0000aa">if</font><font color="#000000"> degree </font><font color="#660096">&gt;=</font><font color="#000000"> </font><font color="#963700">2</font><font color="#000000">
  [
    filterPath tmpValidList
  ]
</font><font color="#007f69">end</font><font color="#000000">
</font><font color="#007f69">to-report</font><font color="#000000"> isConnect? [streetId1 streetId2]
  </font><font color="#0000aa">let</font><font color="#000000"> street-adjacent </font><font color="#660096">item</font><font color="#000000"> streetId1 street-list
  </font><font color="#0000aa">set</font><font color="#000000"> street-adjacent </font><font color="#660096">sublist</font><font color="#000000"> street-adjacent </font><font color="#963700">1</font><font color="#000000"> (</font><font color="#660096">length</font><font color="#000000"> street-adjacent)
  </font><font color="#0000aa">foreach</font><font color="#000000"> street-adjacent
  [
    </font><font color="#0000aa">let</font><font color="#000000"> a-street ?
    </font><font color="#0000aa">let</font><font color="#000000"> a-street-id </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">0</font><font color="#000000"> a-street
    </font><font color="#0000aa">if</font><font color="#000000"> a-street-id </font><font color="#660096">=</font><font color="#000000"> streetId2
    [
      </font><font color="#0000aa">report</font><font color="#000000"> </font><font color="#963700">true</font><font color="#000000">
    ]
  ]
  </font><font color="#0000aa">report</font><font color="#000000"> </font><font color="#963700">false</font><font color="#000000">
</font><font color="#007f69">end</font><font color="#000000">
</font><font color="#007f69">to</font><font color="#000000"> TopoSteps [streetId]
  </font><font color="#0000aa">set</font><font color="#000000"> currLineDepth (</font><font color="#660096">list</font><font color="#000000">)
  </font><font color="#0000aa">let</font><font color="#000000"> i </font><font color="#963700">0</font><font color="#000000">
  </font><font color="#0000aa">while</font><font color="#000000"> [i </font><font color="#660096">&lt;</font><font color="#000000"> maxBound]
  [
    </font><font color="#0000aa">set</font><font color="#000000"> currLineDepth </font><font color="#660096">lput</font><font color="#000000"> </font><font color="#963700">0</font><font color="#000000"> currLineDepth  </font><font color="#5a5a5a">; Initialize the currLineDepth</font><font color="#000000">
    </font><font color="#0000aa">set</font><font color="#000000"> i i </font><font color="#660096">+</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000">
  ]
  </font><font color="#0000aa">set</font><font color="#000000"> currLevel </font><font color="#963700">0</font><font color="#000000">
  </font><font color="#0000aa">let</font><font color="#000000"> localPoints1 (</font><font color="#660096">list</font><font color="#000000">)
  
  </font><font color="#0000aa">let</font><font color="#000000"> street-adjacent </font><font color="#660096">item</font><font color="#000000"> streetId street-list
  </font><font color="#0000aa">set</font><font color="#000000"> street-adjacent </font><font color="#660096">sublist</font><font color="#000000"> street-adjacent </font><font color="#963700">1</font><font color="#000000"> (</font><font color="#660096">length</font><font color="#000000"> street-adjacent)
  </font><font color="#0000aa">foreach</font><font color="#000000"> street-adjacent
  [
    </font><font color="#0000aa">let</font><font color="#000000"> a-street ?
    </font><font color="#0000aa">let</font><font color="#000000"> a-street-id </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">0</font><font color="#000000"> a-street
    </font><font color="#0000aa">set</font><font color="#000000"> localPoints1 </font><font color="#660096">lput</font><font color="#000000"> a-street-id localPoints1    
  ]
  
  </font><font color="#0000aa">let</font><font color="#000000"> sndj </font><font color="#963700">0</font><font color="#000000">
  </font><font color="#0000aa">foreach</font><font color="#000000"> street-adjacent
  [
    </font><font color="#0000aa">let</font><font color="#000000"> a-street ?
    </font><font color="#0000aa">let</font><font color="#000000"> a-street-id </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">0</font><font color="#000000"> a-street
    </font><font color="#0000aa">set</font><font color="#000000"> sndj a-street-id
    </font><font color="#0000aa">set</font><font color="#000000"> currLineDepth </font><font color="#660096">replace-item</font><font color="#000000"> sndj currLineDepth </font><font color="#963700">1</font><font color="#000000">
  ]
  
  </font><font color="#0000aa">set</font><font color="#000000"> currLevel </font><font color="#963700">2</font><font color="#000000">
  recurDegree streetId localPoints1
</font><font color="#007f69">end</font><font color="#000000">
</font><font color="#007f69">to</font><font color="#000000"> recurDegree [currLineNo localPoints1]
  </font><font color="#0000aa">let</font><font color="#000000"> connj </font><font color="#963700">0</font><font color="#000000">
  </font><font color="#0000aa">let</font><font color="#000000"> recurConnPoints (</font><font color="#660096">list</font><font color="#000000">)
  </font><font color="#0000aa">foreach</font><font color="#000000"> localPoints1
  [
    </font><font color="#0000aa">set</font><font color="#000000"> connj ?
    </font><font color="#0000aa">let</font><font color="#000000"> rdj </font><font color="#963700">0</font><font color="#000000">
    </font><font color="#0000aa">let</font><font color="#000000"> street-list-ele </font><font color="#660096">item</font><font color="#000000"> connj street-list
    </font><font color="#0000aa">set</font><font color="#000000"> street-list-ele </font><font color="#660096">sublist</font><font color="#000000"> street-list-ele </font><font color="#963700">1</font><font color="#000000"> (</font><font color="#660096">length</font><font color="#000000"> street-list-ele)
    </font><font color="#0000aa">foreach</font><font color="#000000"> street-list-ele
    [
      </font><font color="#0000aa">set</font><font color="#000000"> rdj </font><font color="#660096">item</font><font color="#000000"> </font><font color="#963700">0</font><font color="#000000"> ?
      </font><font color="#0000aa">ifelse</font><font color="#000000"> rdj </font><font color="#660096">=</font><font color="#000000"> currLineNo
      []    </font><font color="#5a5a5a">;???????</font><font color="#000000">
      [
        </font><font color="#0000aa">let</font><font color="#000000"> a-index </font><font color="#660096">item</font><font color="#000000"> rdj currLineDepth
        </font><font color="#0000aa">if</font><font color="#000000"> a-index </font><font color="#660096">=</font><font color="#000000"> </font><font color="#963700">0</font><font color="#000000">
        [
          </font><font color="#0000aa">set</font><font color="#000000"> currLineDepth </font><font color="#660096">replace-item</font><font color="#000000"> rdj currLineDepth currLevel
          </font><font color="#0000aa">set</font><font color="#000000"> recurConnPoints </font><font color="#660096">lput</font><font color="#000000"> rdj recurConnPoints
        ]
      ]
    ]
  ]
  </font><font color="#0000aa">if</font><font color="#000000"> (</font><font color="#660096">length</font><font color="#000000"> recurConnPoints)</font><font color="#660096">&gt;</font><font color="#000000"> </font><font color="#963700">0</font><font color="#000000">
  [
    </font><font color="#0000aa">set</font><font color="#000000"> currLevel currLevel </font><font color="#660096">+</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000">
    recurDegree currLineNo recurConnPoints
  ]
  </font><font color="#0000aa">set</font><font color="#000000"> recurConnPoints (</font><font color="#660096">list</font><font color="#000000">)
</font><font color="#007f69">end</font><font color="#000000">
</font><font color="#007f69">to-report</font><font color="#000000"> sudLine [streetId x1 y1 x2 y2]
  </font><font color="#0000aa">ifelse</font><font color="#000000"> (</font><font color="#660096">abs</font><font color="#000000">(x1 </font><font color="#660096">-</font><font color="#000000"> x2) </font><font color="#660096">&lt;</font><font color="#000000"> simulation-speed) </font><font color="#660096">and</font><font color="#000000"> (</font><font color="#660096">abs</font><font color="#000000">(y1 </font><font color="#660096">-</font><font color="#000000"> y2) </font><font color="#660096">&lt;</font><font color="#000000"> simulation-speed)
  [
    </font><font color="#0000aa">let</font><font color="#000000"> lineInfo (</font><font color="#660096">list</font><font color="#000000"> </font><font color="#963700">0</font><font color="#000000">)
    </font><font color="#0000aa">set</font><font color="#000000"> lineInfo </font><font color="#660096">lput</font><font color="#000000"> (</font><font color="#660096">list</font><font color="#000000"> streetId x1 y1 x2 y2) lineInfo
    </font><font color="#0000aa">report</font><font color="#000000"> lineInfo
  ]
  [
    </font><font color="#0000aa">let</font><font color="#000000"> lineInfo (</font><font color="#660096">list</font><font color="#000000"> </font><font color="#963700">1</font><font color="#000000">)
    </font><font color="#0000aa">set</font><font color="#000000"> lineInfo </font><font color="#660096">lput</font><font color="#000000"> (</font><font color="#660096">list</font><font color="#000000"> streetId x1 y1 x2 y2) lineInfo
    </font><font color="#0000aa">report</font><font color="#000000"> lineInfo
  ]
</font><font color="#007f69">end</font>
</pre>

</body>
</html>
